Skip to content

Commit 307cfec

Browse files
committed
[ci skip] Update UG for changes
1 parent 5fd639e commit 307cfec

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

user_guide_src/source/changelogs/v4.1.2.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ Release Date: Not released
55

66
**4.1.2 release of CodeIgniter4**
77

8+
BREAKING:
9+
10+
Fixed `a bug <https://github.com/codeigniter4/CodeIgniter4/issues/4116>`_ in ``current_url()`` that prevented
11+
configurations with an ``indexPage`` from including that value in the return value. Any installations
12+
using ``App::$indexPage`` should expect altered values from ``current_url()`` and all its dependencies
13+
(including Response Testing, Pager, Form Helper, Pager, and View Parser).
14+
815
Enhancements:
916

1017
- New HTTP classes, ``Cookie`` and ``CookieStore``, for abstracting web cookies.

user_guide_src/source/helpers/url_helper.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ The following functions are available:
8181
This would give you something like:
8282
*http://example.com/images/icons/edit.png*
8383

84-
.. php:function:: current_url([$returnObject = false])
84+
.. php:function:: current_url([$returnObject = false[, $request = null]])
8585
8686
:param boolean $returnObject: True if you would like a URI instance returned, instead of a string.
87+
:param IncomingRequest|null $request: An alternate request to use for path detection; useful for testing.
8788
:returns: The current URL
8889
:rtype: string|\\CodeIgniter\\HTTP\\URI
8990

@@ -93,7 +94,9 @@ The following functions are available:
9394
.. note:: Calling this function is the same as doing this:
9495
::
9596

96-
base_url(uri_string());
97+
site_url(uri_string());
98+
99+
.. important:: Prior to **4.1.2** this function had a bug causing it to ignore the configuration on ``App::$indexPage``.
97100

98101
.. php:function:: previous_url([$returnObject = false])
99102

user_guide_src/source/libraries/uri.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ into its appropriate sections::
3131
The Current URI
3232
---------------
3333

34-
Many times, all you really want is an object representing the current URL of this request. This can be accessed
35-
in two different ways. The first is to grab it directly from the current request object. Assuming that you're in
36-
a controller that extends ``CodeIgniter\Controller`` you can get it like::
37-
38-
$uri = $this->request->uri;
39-
40-
Second, you can use one of the functions available in the **url_helper**::
34+
Many times, all you really want is an object representing the current URL of this request.
35+
You can use one of the functions available in the **url_helper**::
4136

4237
$uri = current_url(true);
43-
38+
4439
You must pass ``true`` as the first parameter, otherwise, it will return the string representation of the current URL.
40+
This URI is based on the path (relative to your ``baseURL``) as determined by the current request object and
41+
your settings in ``Config\App`` (baseURL, indexPage, and forceGlobalSecureRequests).
42+
Assuming that you're in a controller that extends ``CodeIgniter\Controller`` you can get this relative path::
43+
44+
$path = $this->request->getPath();
4545

4646
===========
4747
URI Strings
@@ -51,7 +51,7 @@ Many times, all you really want is to get a string representation of a URI. This
5151
the URI as a string::
5252

5353
$uri = current_url(true);
54-
echo (string)$uri; // http://example.com
54+
echo (string) $uri; // http://example.com/index.php
5555

5656
If you know the pieces of the URI and just want to ensure it's all formatted correctly, you can generate a string
5757
using the URI class' static ``createURIString()`` method::

0 commit comments

Comments
 (0)