user_guide_src/source/changelogs/v4.4.0.rst
Version 4.4.0 #############
Release Date: August 25, 2023
4.4.0 release of CodeIgniter4
.. contents:: :local: :depth: 3
Highlights
lonnieezell <https://github.com/lonnieezell>).
See Testing.BREAKING
An exception is now thrown when you set the last +2 segment.
In previous versions, an exception was thrown only if the last segment +3
or more was specified. See :ref:upgrade-440-uri-setsegment.
The next segment (+1) of the current last segment can be set as before.
.. _v440-factories:
Passing Classname with Namespace ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Now preferApp works only when you request
:ref:a classname without a namespace <factories-passing-classname-without-namespace>.
For example, when you call model(\Myth\Auth\Models\UserModel::class) or
model('Myth\Auth\Models\UserModel'):
before:
App\Models\UserModel if exists and preferApp is true (default)Myth\Auth\Models\UserModel if exists and preferApp is falseafter:
Myth\Auth\Models\UserModel even if preferApp is true (default)App\Models\UserModel if you define Factories::define('models', 'Myth\Auth\Models\UserModel', 'App\Models\UserModel') before calling the model()If you had passed a non-existent classname by mistake, the previous version
would have returned a class instance in the App or Config namespace
because of the preferApp feature.
For example, in a controller (namespace App\Controllers), if you called
config(Config\App::class) by mistake (note the class is missing the leading \),
meaning you actually passed App\Controllers\Config\App.
But that class does not exist, so now Factories will return null.
Property Name ^^^^^^^^^^^^^
The property Factories::$basenames has been renamed to $aliases.
Previously, CodeIgniter's autoloader allowed loading class names ending with the .php extension. This means instantiating objects like new Foo.php() was possible
and would instantiate as new Foo(). Since Foo.php is an invalid class name, this behavior of the autoloader is changed. Now, instantiating such classes would fail.
.. _v440-codeigniter-and-exit:
The CodeIgniter::run() method no longer calls exit(EXIT_SUCCESS). The
exit call is moved to public/index.php.
.. _v440-site-uri-changes:
A new SiteURI class that extends the URI class and represents the site
URI has been added, and now it is used in many places that need the current URI.
$this->request->getUri() in controllers returns the SiteURI instance.
Also, :php:func:site_url(), :php:func:base_url(), and :php:func:current_url()
use the SiteURI internally.
getPath() ^^^^^^^^^
The getPath() method now always returns the full URI path with leading /.
Therefore, when your baseURL has sub-directories and you want to get the relative
path to baseURL, you must use the new getRoutePath() method instead.
For example::
baseURL: http://localhost:8888/CodeIgniter4/
The current URI: http://localhost:8888/CodeIgniter4/foo/bar
getPath(): /CodeIgniter4/foo/bar
getRoutePath(): foo/bar
Site URI Values ^^^^^^^^^^^^^^^
The SiteURI class normalizes site URIs more strictly than before, and some bugs have been fixed.
As a result, the framework may return site URIs or the URI paths slightly differently
than in previous versions.
For example, / will be added after index.php::
http://example.com/test/index.php?page=1
↓
http://example.com/test/index.php/?page=1
.. _v440-interface-changes:
.. note:: As long as you have not extended the relevant CodeIgniter core classes or implemented these interfaces, all these changes are backward compatible and require no intervention.
getValidated() method in ValidationInterface... _v440-method-signature-changes:
.. _v440-parameter-type-changes:
Services::security() has been changed from
Config\App to Config\Security.Services::session() has been changed from
Config\App to Config\Session.Session::__construct() has been changed from
Config\App to Config\Session.__construct() in the database's BaseHandler,
DatabaseHandler, FileHandler, MemcachedHandler, and RedisHandler
has been changed from Config\App to Config\Session.Security::__construct() has been
changed from Config\App to Config\Security.Validation::check() has been changed.
The string typehint on the $rule parameter was removed.CodeIgniter::setRequest() has been
changed. The Request typehint on the $request parameter was removed.FeatureTestCase::populateGlobals() has been
changed. The Request typehint on the $request parameter was removed.FeatureTestCase::setRequestBody() has been
changed. The Request typehint on the $request parameter and the
return type Request were removed.Routing $routing has been added to
RouteCollection::__construct().$request and the third parameter
$response in Services::exceptions() have been removed.$request and the third parameter
$response in CodeIgniter\Debug\Exceptions::__construct() have been removed.loadClass and loadClassmap methods are made void
to be compatible as callbacks in spl_autoload_register and spl_autoload_unregister functions.Enhancements
Now you can specify the host in the request URL.
See :ref:routing-spark-routes-specify-host.
It shows view files of :ref:view-routes in Handler like the following:
+---------+-------------+------+------------------------------+----------------+---------------+ | Method | Route | Name | Handler | Before Filters | After Filters | +---------+-------------+------+------------------------------+----------------+---------------+ | GET | about | » | (View) pages/about | | toolbar | +---------+-------------+------+------------------------------+----------------+---------------+
debug-toolbar-hot-reload.view-routes are displayed in DEFINED ROUTES on the Routes tab.numberNative attribute to the Database Config to keep the variable type obtained after SQL Query consistent with the type set in the database.
See :ref:Database Configuration <database-config-explanation-of-values>.nullable. See :ref:db-metadata-getfielddata.entities-special-getter-setter.Validation::getValidated() method that gets
the actual validated data. See :ref:validation-getting-validated-data for details.$quality can now be used to compress WebP images.UploadedFiles::getClientPath() method that returns
the value of the full_path index of the file if it was uploaded via directory upload.proxy. See
:ref:CURLRequest Class <curlrequest-request-options-proxy>.SiteURI class that extends URI and represents the site
URI has been added.array_group_by() helper function to group data
values together. Supports dot-notation syntax.force_https() no longer terminates the application, but throws a RedirectException.DownloadResponse::inline() method that sets
the Content-Disposition: inline header to display the file in the browser.
See :ref:open-file-in-browser for details.$saveData on renderSection() to prevent from auto cleans the data after displaying. See :ref:View Layouts <creating-a-layout> for details.auto-routing-improved-module-routing
for details.auto-routing-improved-default-method-fallback for details.$filters property <filters-filters-filter-arguments>.IncomingRequest::setValidLocales() method to set valid locales.Table::setSyncRowsWithHeading() method to synchronize row columns with headings. See :ref:table-sync-rows-with-headings for details.custom-exception-handlers.ResponseInterface as its first argument.ResponsableInterface.factories-defining-classname-to-be-loaded.factories-config-caching for details.Message Changes
Core.invalidDirectory error message.HTTP.invalidHTTPProtocol error message.Changes
GDHandler has been changed from 80 to 90.Upgrading Guide <upgrade-440-config-routing>.Content-Disposition header if it was previously specified./, _, ., :, \ and space.
So if you installed CodeIgniter under the folder that contains the special
characters like (, ), etc., CodeIgniter didn't work. Since v4.4.0,
this restriction has been removed.Autoloader::loadClass() and Autoloader::loadClassmap() are now both
marked @internal.$routes
has been modified for performance.force_https() or
Config\App::$forceGlobalSecureRequests = true sets the HTTP status code 307,
which allows the HTTP request method to be preserved after the redirect.
In previous versions, it was 302.Deprecations
Entity::setAttributes() is deprecated. Use Entity::injectRawData() instead.CodeIgniter\Debug\Exceptions
are deprecated. Because these methods have been moved to BaseExceptionHandler or
ExceptionHandler.Autoloader::sanitizeFilename() is deprecated.CodeIgniter::$returnResponse property is deprecated. No longer used.CodeIgniter::$cacheTTL property is deprecated. No longer used. Use ResponseCache instead.CodeIgniter::cache() method is deprecated. No longer used. Use ResponseCache instead.CodeIgniter::cachePage() method is deprecated. No longer used. Use ResponseCache instead.CodeIgniter::generateCacheName() method is deprecated. No longer used. Use ResponseCache instead.CodeIgniter::callExit() method is deprecated. No longer used.\CodeIgniter\Router\Exceptions\RedirectException is deprecated. Use \CodeIgniter\HTTP\Exceptions\RedirectException instead.$sessionDriverName, $sessionCookieName,
$sessionExpiration, $sessionSavePath, $sessionMatchIP,
$sessionTimeToUpdate, and $sessionRegenerateDestroy in Session are
deprecated, and no longer used. Use $config instead.$csrfProtection, $tokenRandomize,
$tokenName, $headerName, $expires, $regenerate, and
$redirect in Security are deprecated, and no longer used. Use
$config instead.URI::$uriString is deprecated.URI::$baseURL is deprecated. Use SiteURI instead.URI::setSilent() is deprecated.URI::setScheme() is deprecated. Use withScheme() instead.URI::setURI() is deprecated.IncomingRequest::detectURI() is deprecated and no longer used.IncomingRequest::detectPath() is deprecated, and no longer used. It
moved to SiteURIFactory.IncomingRequest::parseRequestURI() is deprecated, and no longer used. It
moved to SiteURIFactory.IncomingRequest::parseQueryString() is deprecated, and no longer used. It
moved to SiteURIFactory.IncomingRequest::setPath() is deprecated.Bugs Fixed
$translateURIDashes
is true, two URIs correspond to a single controller method, one URI for dashes
(e.g., foo-bar) and one URI for underscores (e.g., foo_bar). This bug
has been fixed. Now the URI for underscores (foo_bar) is not accessible.ControllerTestTrait::withUri() creates a new Request
instance with the URI. Because the Request instance should have the URI instance.
Also if the hostname in the URI string is invalid with Config\App, the valid
hostname will be set.See the repo's
CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>_
for a complete list of bugs fixed.