user_guide_src/source/installation/upgrade_460.rst
############################# Upgrading from 4.5.8 to 4.6.0 #############################
Please refer to the upgrade instructions corresponding to your installation method.
Composer Installation App Starter Upgrading <app-starter-upgrading>Composer Installation Adding CodeIgniter4 to an Existing Project Upgrading <adding-codeigniter4-upgrading>Manual Installation Upgrading <installing-manual-upgrading>.. contents:: :local: :depth: 2
Breaking Changes
Some classes have changed the exception classes that are thrown. Some exception
classes have changed parent classes.
See :ref:ChangeLog <v460-behavior-changes-exceptions> for details.
If you have code that catches these exceptions, change the exception classes.
.. _upgrade-460-time-create-from-timestamp:
When you do not explicitly pass a timezone, now
:ref:Time::createFromTimestamp() <time-createfromtimestamp> returns a Time
instance with UTC. In v4.4.6 to prior to v4.6.0, a Time instance with the
currently set default timezone was returned.
This behavior change normalizes behavior with changes in PHP 8.4 which adds a
new DateTimeInterface::createFromTimestamp() method.
If you want to keep the default timezone, you need to pass the timezone as the second parameter::
use CodeIgniter\I18n\Time;
$time = Time::createFromTimestamp(1501821586, date_default_timezone_get());
.. _upgrade-460-time-keeps-microseconds:
In previous versions, :doc:Time <../libraries/time> lost microseconds in some
cases. But the bugs have been fixed.
The results of the Time comparison may differ due to these fixes:
.. literalinclude:: upgrade_460/006.php :lines: 2-
In a such case, you need to remove the microseconds:
.. literalinclude:: upgrade_460/007.php :lines: 2-
The following cases now keeps microseconds:
.. literalinclude:: upgrade_460/002.php :lines: 2-
.. literalinclude:: upgrade_460/003.php :lines: 2-
Note that Time with the current time has been holding microseconds since before.
.. literalinclude:: upgrade_460/004.php :lines: 2-
Also, methods that returns an int still lose the microseconds.
.. literalinclude:: upgrade_460/005.php :lines: 2-
.. _upgrade-460-time-set-timestamp:
In previous versions, if you call Time::setTimestamp() on a Time instance with
a timezone other than the default timezone might return a Time instance with the
wrong date/time.
This bug has been fixed, and it now behaves in the same way as DateTimeImmutable:
.. literalinclude:: upgrade_460/008.php :lines: 2-
Note that if you use the default timezone, the behavior is not changed:
.. literalinclude:: upgrade_460/009.php :lines: 2-
.. _upgrade-460-registrars-with-dirty-hack:
To prevent Auto-Discovery of :ref:registrars from running twice, when a registrar
class is loaded or instantiated, if it instantiates a Config class (which extends
CodeIgniter\Config\BaseConfig), ConfigException will be raised.
This is because if Auto-Discovery of Registrars is performed twice, duplicate values may be added to properties of Config classes.
All registrar classes (Config/Registrar.php in all namespaces) must be modified so that they do not instantiate any Config class when loaded or instantiated.
If the packages/modules you are using provide such registrar classes, the registrar classes in the packages/modules need to be fixed.
The following is an example of code that will no longer work:
.. literalinclude:: upgrade_460/001.php
.. _upgrade-460-sid-change:
Now :doc:../libraries/sessions forces to use the PHP default 32 character SIDs,
with 4 bits of entropy per character. This change is to match the behavior of
PHP 9.
In other words, the following settings are always used:
.. code-block:: ini
session.sid_bits_per_character = 4
session.sid_length = 32
In previous versions, the PHP ini settings was respected. So this change may change your SID length.
If you cannot accept this change, customize the Session library.
Some interface changes have been made. Classes that implement them should update
their APIs to reflect the changes. See :ref:ChangeLog <v460-interface-changes>
for details.
Some method signature changes have been made. Classes that extend them should
update their APIs to reflect the changes. See :ref:ChangeLog <v460-method-signature-changes>
for details.
Some deprecated items have been removed. If you are still using these items, or
extending these classes, upgrade your code.
See :ref:ChangeLog <v460-removed-deprecated-items> for details.
Breaking Enhancements
.. _upgrade-460-filters-changes:
The Filters class has been changed to allow multiple runs of the same filter
with different arguments in before or after.
If you are extending Filters, you will need to modify it to conform to the
following changes:
$filters and $filtersClasses have
been changed.$arguments and $argumentsClass are no longer used.Filters has been changed so that the same filter class is not instantiated
multiple times. If a filter class is used both before and after, the same instance
is used.Project Files
Some files in the project space (root, app, public, writable) received updates. Due to these files being outside of the system scope they will not be changed without your intervention.
There are some third-party CodeIgniter modules available to assist with merging changes to
the project space: Explore on Packagist <https://packagist.org/explore/?query=codeigniter4%20updates>_.
The following files received significant changes (including deprecations or visual adjustments) and it is recommended that you merge the updated versions with your application:
Config\Feature::$autoRoutesImproved has been changed to true.Config\Feature::$strictLocaleNegotiation has been added.Config\Routing::$translateUriToCamelCase has been changed to true.Config\Kint::$richSort has been removed. Kint in v6 no longer uses AbstractRenderer::SORT_FULL. Leaving this property in your code will cause a runtime error due to the undefined constant.This is a list of all files in the project space that received changes; many will be simple comments or formatting that have no effect on the runtime: