diff --git a/user_guide_src/source/changelogs/v4.5.4.rst b/user_guide_src/source/changelogs/v4.5.4.rst index 51a9fd74f407..7b3c2ab065f5 100644 --- a/user_guide_src/source/changelogs/v4.5.4.rst +++ b/user_guide_src/source/changelogs/v4.5.4.rst @@ -32,6 +32,9 @@ Bugs Fixed - **CURLRequest:** Fixed a bug preventing the use of strings for ``version`` in the config array when making requests. +- **Registrars:** Added check to prevent Auto-Discovery of Registrars from running + twice. If it is executed twice, an exception will be raised. See + :ref:`upgrade-454-registrars-with-dirty-hack`. See the repo's `CHANGELOG.md `_ diff --git a/user_guide_src/source/installation/upgrade_454.rst b/user_guide_src/source/installation/upgrade_454.rst index 393324c3b40c..2995eef14955 100644 --- a/user_guide_src/source/installation/upgrade_454.rst +++ b/user_guide_src/source/installation/upgrade_454.rst @@ -20,6 +20,28 @@ Mandatory File Changes Breaking Changes **************** +.. _upgrade-454-registrars-with-dirty-hack: + +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_454/001.php + ********************* Breaking Enhancements ********************* diff --git a/user_guide_src/source/installation/upgrade_454/001.php b/user_guide_src/source/installation/upgrade_454/001.php new file mode 100644 index 000000000000..6d55ef67d336 --- /dev/null +++ b/user_guide_src/source/installation/upgrade_454/001.php @@ -0,0 +1,33 @@ + [ + 'module_pager' => 'MyModule\Views\Pager', + ], + ]; + } + + public static function hack(): void + { + $config = config('Cache'); + + // Does something. + } +} + +Registrar::hack(); // Bad. When this class is loaded, Config\Cache will be instantiated.