Release Date: Unreleased
4.6.0 release of CodeIgniter4
- TBD
The exception class has been redesigned. See :ref:`exception-design` for details. The following breaking changes have been made accordingly:
Validation::setRule()now throwsCodeIgniter\Exceptions\InvalidArgumentExceptioninstead ofTypeError.CriticalErrornow extendsCodeIgniter\Exceptions\RuntimeExceptioninstead ofError.DatabaseExceptionnow extendsCodeIgniter\Exceptions\RuntimeExceptioninstead ofError.ConfigExceptionnow extendsCodeIgniter\Exceptions\RuntimeExceptioninstead ofCodeIgniter\Exceptions\CriticalError.TestExceptionnow extendsCodeIgniter\Exceptions\LogicExceptioninstead ofCodeIgniter\Exceptions\CriticalError.
The Filters class has been changed to allow multiple runs of the same filter
with different arguments in before or after. See
:ref:`Upgrading Guide <upgrade-460-filters-changes>` for details.
Added check to prevent Auto-Discovery of Registrars from running twice. If it is executed twice, an exception will be thrown. See :ref:`upgrade-460-registrars-with-dirty-hack`.
Time::createFromTimestamp() handles timezones differently. If $timezone
is not explicitly passed then the instance has timezone set to UTC unlike earlier
where the currently set default timezone was used.
See :ref:`Upgrading Guide <upgrade-460-time-create-from-timestamp>` for details.
Fixed bugs that some methods in Time to lose microseconds have been fixed.
See :ref:`Upgrading Guide <upgrade-460-time-keeps-microseconds>` for details.
Time::setTimestamp() behavior has been fixed.
See :ref:`Upgrading Guide <upgrade-460-time-set-timestamp>` for details.
In previous versions, when a request does not accept HTML, CodeIgniter showed
error details only in the development and testing environments.
But because it is not possible to display error details when using a custom
environment, this behavior has been fixed so that error details are displayed if
display_errors in PHP ini setting is enabled.
With this fix, the error details are now displayed under the same conditions for both HTML requests and non-HTML requests.
Now Session library forces to use the PHP default 32 character SIDs, with 4
bits of entropy per character.
See :ref:`Upgrading Guide <upgrade-460-sid-change>` for details.
The headers set by the Response class replace those that can be set by the PHP
header() function.
In previous versions, headers set by the Response class were added to existing
ones - giving no options to change them. That could lead to unexpected behavior when
the same headers were set with mutually exclusive directives.
For example, session will automatically set headers with the header() function:
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
So if we set Expires header one more time we will end up with a duplicated header:
$response->removeHeader('Expires'); // has no effect
return $response->setHeader('Expires', 'Sun, 17 Nov 2024 14:17:37 GMT');Response headers:
Expires: Thu, 19 Nov 1981 08:52:00 GMT
// ...
Expires: Sun, 17 Nov 2024 14:17:37 GMT
Now, we don't know which one will be picked by the browser or which header is the correct one. With changes in this version our previous header will be overridden:
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Expires: Sun, 17 Nov 2024 14:17:37 GMT
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.
Router: The following methods have been added in
RouteCollectionInterface:getDefaultNamespace()getRoutesOptions()setHTTPVerb()isFiltered()getFiltersForRoute()
- Router: The constructor of the
DefinedRouteCollectorhas been changed. TheRouteCollectiontypehint has been changed toRouteCollectionInterface. - View: The return type of the
renderSection()method has been changed tostring, and now the method does not callecho. - Time: The first parameter type of the
createFromTimestamp()has been changed frominttoint|float, and the return typestatichas been added. - Helpers:
character_limiter()parameter names have been updated. If you use named arguments, you need to update the function calls.
- Database:
- The type
stringof the first parameter inBaseConnection::escapeIdentifier()has been removed. - The type
stringof the first parameter inBaseConnection::getFieldNames()andSQLite3\Connection::getFieldNames()have been removed. - The type
stringof the first parameter inBaseConnection::_listColumns()andMySQLi\Connection::_listColumns()andOCI8\Connection::_listColumns()andPostgre\Connection::_listColumns()andSQLSRV\Connection::_listColumns()andSQLite3\Connection::_listColumns()have been removed.
- The type
- API: The deprecated
failValidationError()method inCodeIgniter\API\ResponseTraithas been removed. UsefailValidationErrors()instead. - HTTP: The deprecated
getReason()method inCodeIgniter\HTTP\ResponseandResponseInterfacehas been removed. UsegetReasonPhrase()instead. - Logger: The deprecated
CodeIgniter\Log\Logger::cleanFilenames()andCodeIgniter\Test\TestLogger::cleanup()have been removed. Use theclean_path()function instead. - Router: The deprecated
CodeIgniter\Router\Exceptions\RedirectExceptionhas been removed. UseCodeIgniter\HTTP\Exceptions\RedirectExceptioninstead. - Constants: The deprecated constants
EVENT_PRIORITY_*in has been removed. Use the class constantsCodeIgniter\Events\Events::PRIORITY_LOW,CodeIgniter\Events\Events::PRIORITY_NORMALandCodeIgniter\Events\Events::PRIORITY_HIGHinstead. - View: The deprecated property
CodeIgniter\View\View::$currentSectionhas been removed. - Config: The deprecated property
Config\Cache::$storePathhas been removed. UseConfig\Cache::$file['storePath']instead. - Formatter: The deprecated
Config\Format::getFormatter()has been removed. UseCodeIgniter\Format\Format::getFormatter()instead. - Security:
Config\Security::$samesitehas been removed. UseConfig\Cookie::$samesiteinstead. - Cookie: Methods
dispatch(),setRawCookie(),setCookie()inCodeIgniter\Cookie\CookieStorehas been removed. They are now part ofCodeIgniter\HTTP\ResponseTrait.
Publisher::discover()now accepts a second parameter (namespace) specifying the namespace in which publishers should be searched. See :ref:`discovery-in-a-specific-namespace` for the details.
The exception class has been redesigned. See :ref:`exception-design` for details. The following new Exception classes have been added accordingly:
CodeIgniter\Exceptions\LogicExceptionCodeIgniter\Exceptions\RuntimeExceptionCodeIgniter\Exceptions\BadFunctionCallExceptionCodeIgniter\Exceptions\BadMethodCallExceptionCodeIgniter\Exceptions\InvalidArgumentException
The following new Exception interfaces have been added:
CodeIgniter\Files\Exceptions\ExceptionInterfaceCodeIgniter\HTTP\Exceptions\ExceptionInterfaceCodeIgniter\Router\Exceptions\ExceptionInterface
Displaying exceptions for non-HTML responses now rely on the PHP display_errors setting instead of hardcoded environments.
- The
spark routesandspark filter:checkcommands now display filter arguments. - The
spark filter:checkcommand now displays filter classnames. - The
spark lang:synccommand to synchronize translation files. See :ref:`sync-translations-command` - The
spark phpini:checkcommand now has an optionalopcacheargument, which when used will display information about opcache settings.
- Now you can specify multiple hostnames when restricting routes.
- Added a feature flag
Feature::$strictLocaleNegotiationto enable strict locale comparision. Previously, response with language headersAccept-language: en-US,en-GB;q=0.9returned the first allowed languageencould instead of the exact languageen-USoren-GB. Set the value totrueto enable comparison not only by language code ('en' - ISO 639-1) but also by regional code ('en-US' - ISO 639-1 plus ISO 3166-1 alpha).
- Added a new feature to get the total and the range number of items of the current page. See :ref:`Displaying the Number of Items on the Page <displaying-the-number-of-items-on-the-page>` for more details.
- Added a new configuration
foundRowsfor MySQLi to useMYSQLI_CLIENT_FOUND_ROWS. - Added the
BaseConnection::resetTransStatus()method to reset the transaction status. See :ref:`transactions-resetting-transaction-status` for details. - SQLite3 has a new Config item
synchronousto adjust how strict SQLite is at flushing to disk during transactions. Modifying this can be useful if we use journal mode set toWAL.
- File: Added
getSizeByBinaryUnit()andgetSizeByMetricUnit()toFileclass. See :ref:`File::getSizeByBinaryUnit() <file-get-size-by-binary-unit>` and :ref:`File::getSizeByMetricUnit() <file-get-size-by-metric-unit>`. - FileCollection: Added
retainMultiplePatterns()toFileCollectionclass. See :ref:`FileCollection::retainMultiplePatterns() <file-collections-retain-multiple-patterns>`. - Validation: Added
min_dimsvalidation rule toFileRulesclass. See :ref:`Validation <rules-for-file-uploads>`. - Validation: Rules:
is_uniqueandis_not_uniquenow accept the optionaldbGroupas part of the first parameter. See :ref:`Validation <rules-for-general-use>`.
- Filters: Now you can execute a filter more than once with the different arguments in before or after.
- Services: Added
BaseService::resetServicesCache()method to reset the services cache. See :ref:`resetting-services-cache`. - Errors: Added a default error page for "400 Bad Request".
- Added
Validation.min_dimsmessage - Added
Errors.badRequestandErrors.sorryBadRequest
The exception classes have been redesigned. See :ref:`exception-design` for details. The following changes have been made accordingly:
- The
deleteMatching()method in Cache Handler classes now throwsCodeIgniter\Exceptions\BadMethodCallExceptioninstead ofException. Cache\ResponseCache::get()now throwsCodeIgniter\Exceptions\RuntimeExceptioninstead ofException.- Classes that threw
RuntimeExceptionhave been changed to throwCodeIgniter\Exceptions\RuntimeException. - Classes that threw
InvalidArgumentExceptionhave been changed to throwCodeIgniter\Exceptions\InvalidArgumentException. - Classes that threw
LogicExceptionhave been changed to throwCodeIgniter\Exceptions\LogicException. - Classes that threw
BadMethodCallExceptionhave been changed to throwCodeIgniter\Exceptions\BadMethodCallException. - Classes that threw
BadFunctionCallExceptionhave been changed to throwCodeIgniter\Exceptions\BadFunctionCallException. RedirectExceptionnow extendsCodeIgniter\Exceptions\RuntimeExceptioninstead ofException.PageNotFoundExceptionnow extendsCodeIgniter\Exceptions\RuntimeExceptioninstead ofOutOfBoundsException.
- Filters:
- The properties
$argumentsand$argumentsClassofFiltershave been deprecated. No longer used. - The
Filters::getArguments()method has been deprecated. No longer used.
- The properties
- File:
- The function
getSizeByUnit()ofFilehas been deprecated. Use eithergetSizeByBinaryUnit()orgetSizeByMetricUnit()instead.
- The function
- Response:
- Headers set using the
Responseclass are now prioritized and replace headers that can be set manually using the PHPheader()function.
- Headers set using the
- View: Added support for multibyte strings for
View::excerpt(). - Helpers: Added support for multibyte strings for
excerpt().
See the repo's CHANGELOG.md for a complete list of bugs fixed.