user_guide_src/source/changelogs/v4.5.0.rst
############# Version 4.5.0 #############
Release Date: April 7, 2024
4.5.0 release of CodeIgniter4
.. contents:: :local: :depth: 3
Highlights
kenjis <https://github.com/kenjis>_)
See :doc:../libraries/cors.kenjis <https://github.com/kenjis>_).
See :ref:spark_optimize.Enhancements
.. _v450-required-filters:
New :ref:Required Filters <filters-required> have been introduced. They are
special filters that are applied before and after other kinds of filters, and
always applied even if a route does not exist.
The following existing functionalities have been reimplemented as Required Filters.
Force Global Secure Requests <forcehttps>../general/cachingperformancemetricsthe-debug-toolbarThe Benchmark Timers used by Debug Toolbar now collect Required Before Filters and Required After Filters data.
The benchmark points have been changed:
Before
bootstrap: Creating Request and Response objects, Event pre_system, Instantiating RouteCollection object, Loading Routes files, Instantiating Router object,routing: Routing,After
bootstrap: Creating Request and Response objects, Event pre_system.required_before_filters: Instantiating Filters object, Running Required Before Filters.routing: Instantiating RouteCollection object, Loading Routes files, Instantiating Router object, Routing,$translateUriToCamelCase option has been added
that allows using CamelCase controller and method names. See
:ref:translate-uri-to-camelcase.$multipleSegmentsOneParam. When this option is
enabled, a placeholder that matches multiple segments, such as (:any), will
be passed directly as it is to one parameter, even if it contains multiple segments.
See :ref:multiple-uri-segments-as-one-parameter for details.$override404 also receive
a PageNotFoundException message as the first parameter.__invoke() method as the default method. See
:ref:routing-default-method.spark optimize command to optimize configuration for production environment.
See :ref:spark_optimize for the details.spark make:test command to generate a skeleton test file. See
:ref:cli-generators-make-test for the details.spark config:check command to check Config values. See
:ref:confirming-config-values for the details.spark phpini:check command to check important PHP ini settings. See
:ref:spark-phpini-check for the details.spark lang:find command to update translations keys. See :ref:generating-translation-files-via-command for the details.--dbgroup option has been added to the spark db:table command.
See :ref:Database Commands <db-command-specify-the-dbgroup>.seeXPath() and dontSeeXPath()
which allows users to work directly with DOMXPath object, using complex expressions.InputOutput class was added and now you can write tests
for commands more easily if you use MockInputOutput.
See :ref:using-mock-input-output.setUnique(), setOptional() and setValid()
methods to allow calling of Faker's modifiers on each field before faking their values.PHPUnit\Framework\TestCase as it
is not a test. Assertions' return types are now natively typed void... _v450-query-builder-limit-0-behavior:
limit(0) Behavior ^^^^^^^^^^^^^^^^^
Feature::$limitZeroAsAll to fix the incorrect behavior
of limit(0).LIMIT 0 is specified in a SQL statement, 0 records are returned. However,
there is a bug in the Query Builder, and if limit(0) is specified, the
generated SQL statement will have no LIMIT clause and all records will be
returned.$limitZeroAsAll in app/Config/Feature.php be set
to false as this incorrect behavior will be fixed in a future version. See
also :ref:v450-model-findall-limit-0-behavior..).Added a feature to convert data retrieved from a database into the appropriate
PHP type. See :ref:model-field-casting for details.
.. _v450-model-findall-limit-0-behavior:
Feature::$limitZeroAsAll to fix the incorrect behavior
of limit(0) for Query Builder. See :ref:v450-query-builder-limit-0-behavior
for details.findAll(0, $offset)
to findAll(null, $offset).Added a property $updateOnlyChanged whether to update
:doc:Entity <../models/entities>'s only changed fields. If you set this property
to false, when you are updating an Entity, DataException
"There is no data to update" will not raise even if the values in the Entity have
not changed.
See :ref:Using CodeIgniter’s Model <model-update-only-changed> for details.
Now you can configure the date/time format when you save :doc:Time <../libraries/time>
instances. See :ref:model-saving-dates for details.
../libraries/cors filter and class.field_exists that checks the filed exists in the
data to be validated.$dbGroup parameter of Validation::run() now accepts not only
a database group name, but also a database connection instance or an array
of database settings.RedisHandler now can configure the interval time for acquiring locks
($lockRetryInterval) and the number of retries ($lockMaxRetries).RedisHandler.
See :ref:sessions-redishandler-driver for details.Config\Security::$redirect is now, by default, environment-specific.
For production environment, changed to true but is still false for other
environments.CodeIgniter\Boot class has been introduced, replacing
system/bootstrap.php.App namespace in the autoload.psr4 setting in composer.json
may also improve the performance of your app. See :ref:autoloader-application-namespace.file-locator-caching for details.FileLocatorInterface has been added.{memory_usage} to show your memory
usage in your view files, which was supported by CodeIgniter 3.pre_command and post_command for Spark
commands. See :ref:Event Points <event-points-for-cli-apps>.Message::addHeader() method to add another header with
the same name. See :php:meth:CodeIgniter\\HTTP\\Message::addHeader().ResponseCache has been improved to include the request
HTTP method in the cache key. This means that the same URI will be cached separately
if the HTTP method is different.ContentSecurityPolicy::clearDirective() method to clear
existing CSP directives. See :ref:csp-clear-directives.BREAKING
For historical reasons, the framework used HTTP method names in lower case like "get", "post". But the method token is case-sensitive because it might be used as a gateway to object-based systems with case-sensitive method names. By convention, standardized methods are defined in all-uppercase US-ASCII letters. See https://www.rfc-editor.org/rfc/rfc9110#name-overview.
Now the framework uses the correct HTTP method names like "GET", "POST".
Request::getMethod() returns uppercase HTTP methods.CURLRequest::request() does not change the accepted HTTP methods to uppercase.See :ref:upgrade-450-lowercase-http-method-name for details.
The order in which Controller Filters are executed has changed. See
:ref:Upgrading Guide <upgrade-450-filter-execution-order> for details.
Due to a bug fix, the behavior has changed so that options passed to the outer
group() are merged with the options of the inner group().
See :ref:Upgrading Guide <upgrade-450-nested-route-groups-and-options> for details.
Now when a response format is JSON, if you pass string data, the framework returns
a JSON response. In previous versions, it returned a HTML response.
See :ref:Upgrading Guide <upgrade-450-api-response-trait> for details.
:doc:../concepts/factories has been changed to a final class. It is a static
class, and even if it were extended, there is no way to replace it.
PageNotFoundException is thrown
if the controller corresponding to the request URI does not exist.log_message() function and the logger methods in
CodeIgniter\Log\Logger now do not return bool values. The return types
have been fixed to void to follow the PSR-3 interface.\ in the fully qualified classname returned by
FileLocator::findQualifiedNameFromPath() has been removed.getIdValue() method has been changed to abstract.404-override feature does change the Response status
code to 404 by default. See :ref:Upgrading Guide <upgrade-450-404-override>.CodeIgniter\Boot class... 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.
$expire of
the ResponseInterface::setCookie() has been fixed from '' to 0.psr/log <https://packagist.org/packages/psr/log>_ package has
been upgraded to v3.0.0.ValidationInterface::run() has been
changed. The ?string typehint on the $dbGroup parameter was removed... _v450-method-signature-changes:
The third parameter $expire in :php:func:set_cookie() and
:php:meth:CodeIgniter\\HTTP\\Response::setCookie() has been fixed.
The type has been changed from string to int, and the default value has
been changed from '' to 0.
RouteCollection constructor has been changed
from FileLocator to FileLocatorInterface.View constructor has been changed
from FileLocator to FileLocatorInterface.objectToRawArray() method in the Model
and BaseModel classes has been changed from ?array to array.To add declare(strict_types=1) to the framework codebase, the method parameter
type ?string for a value to validate in the all Traditional Validation rule
classes CodeIgniter\Validation\FormatRules and CodeIgniter\Validation\Rules
are removed.
For example, the method signature changed as follows::
Before: public function integer(?string $str = null): bool
After: public function integer($str = null): bool
CodeIgniter\Log\Logger
that implements the PSR-3 interface have been fixed. The bool return
types are changed to void. The $message parameters now have
string|Stringable types.Validation::run() has been
changed. The ?string typehint on the $dbGroup parameter was removed... _v450-removed-deprecated-items:
$upper parameter in getMethod() in RequestInterface and Request
has been removed. See :ref:upgrade-450-lowercase-http-method-name.isValidIP() method in RequestInterface and Request
has been removed.$uri and $config in
IncomingRequest has been changed to protected.$enableCSRF property in IncomingRequest has been removed.removeRelativeDirectory() method in IncomingRequest has been removed.$proxyIPs property in Request has been removed.The following deprecated items have been removed, because now :ref:multiple-filters are always enabled.
Filters::enableFilter()RouteCollection::getFilterForRoute()Router::$filterInfoRouter::getFilter()ModelFactoryBaseModel::idValue()BaseModel::fillPlaceholders()Model::idValue()Model::classToArray()The visibility of the deprecated property ResponseTrait::$CSP has been
changed to protected.
The following deprecated properties have been removed.
ResponseTrait::$CSPEnabledResponseTrait::$cookiePrefixResponseTrait::$cookieDomainResponseTrait::$cookiePathResponseTrait::$cookieSecureResponseTrait::$cookieHTTPOnlyResponseTrait::$cookieSameSiteResponseTrait::$cookiesSecurityInterface::isExpired()Security::isExpired()Security::CSRFVerify()Security::getCSRFHash()Security::getCSRFTokenName()Security::sendCookie()Security::doSendCookie()$path$useSafeOutputuseSafeOutput()setPath()CIDatabaseTestCaseControllerResponseControllerTesterFeatureResponseFeatureTestCaseMock\MockSecurityConfigmigrate:createsession:migrationCodeIgniter\Cache\Exceptions\ExceptionInterface has been removed.CodeIgniter\Config\Config class has been removed.CodeIgniter\Config\BaseService::discoverServices() method
has been removed.Controller::loadHelpers() method has been removed.CodeIgniter\Exceptions\CastException class has been removed.CodeIgniter\Entity class has been removed. Use
CodeIgniter\Entity\Entity instead.SPARKED has been removed.Message Changes
CLI.generator.className.test message.Validation.field_exists error message.Changes
ENVIRONMENT have been
moved before loading of bootstrap.php.Config\Feature::$multipleFilters has been removed, because now
:ref:multiple-filters are always enabled.E_ALL & ~E_DEPRECATED
to match the default php.ini for production.$routes
has been fixed from lowercase to uppercase.CodeIgniter\Exceptions\AlertError and
CodeIgniter\Exceptions\EmergencyError were removed.SQLSRV Forge now converts ENUM data types to VARCHAR(n)
when you add table columns. In previous version, it converted to TEXT that
is deprecated in SQL Server.declare(strict_types=1) has been added to most framework codebase.Deprecations
BaseService::$services property has been deprecated. No
longer used.determinePath() method has been deprecated. No longer used.resolvePlatformExtensions() method has been deprecated. No longer
used. It has been moved to the CodeIgniter\Boot::checkMissingExtensions()
method.bootstrapEnvironment() method has been deprecated. No longer used.
It has been moved to the CodeIgniter\Boot::loadEnvironmentBootstrap()
method.initializeKint() method has been deprecated. No longer used. It has
been moved to the Autoloader.autoloadKint() method has been deprecated. No longer used. It has
been moved to the Autoloader.configureKint() method has been deprecated. No longer used. It has
been moved to the Autoloader.$config has been deprecated. No
longer used.Filters accept the lowercase HTTP method keys
of Config\Filters::$methods has been deprecated. Use correct uppercase
HTTP method keys instead.spark filter:check command accepts the lowercase
HTTP method has been deprecated. Use correct uppercase HTTP method instead.match() and setHTTPVerb()
methods accept the lowercase HTTP methods has been deprecated. Use correct
uppercase HTTP methods instead.call() and withRoutes()
methods accept the lowercase HTTP methods has been deprecated. Use correct
uppercase HTTP methods instead.BaseConnection::$strictOn has been deprecated. It will be
moved to MySQLi\Connection in the future.Bugs Fixed
See the repo's
CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>_
for a complete list of bugs fixed.