Skip to content

Commit c65e05d

Browse files
committed
docs: move "Logging Deprecation Warnings" in section "Configuration"
1 parent 37931d0 commit c65e05d

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

user_guide_src/source/general/errors.rst

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,37 @@ To ignore logging on other status codes, you can set the status code to ignore i
8787
:ref:`Log settings <logging-configuration>`
8888
are not set up to log ``critical`` errors, which all exceptions are logged as.
8989

90+
.. _logging_deprecation_warnings:
91+
92+
Logging Deprecation Warnings
93+
----------------------------
94+
95+
.. versionadded:: 4.3.0
96+
97+
By default, all errors reported by ``error_reporting()`` will be thrown as an ``ErrorException`` object. These
98+
include both ``E_DEPRECATED`` and ``E_USER_DEPRECATED`` errors. With the surge in use of PHP 8.1+, many users
99+
may see exceptions thrown for `passing null to non-nullable arguments of internal functions <https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg>`_.
100+
To ease the migration to PHP 8.1, you can instruct CodeIgniter to log the deprecations instead of throwing them.
101+
102+
First, make sure your copy of ``Config\Exceptions`` is updated with the two new properties and set as follows:
103+
104+
.. literalinclude:: errors/012.php
105+
106+
Next, depending on the log level you set in ``Config\Exceptions::$deprecationLogLevel``, check whether the
107+
logger threshold defined in ``Config\Logger::$threshold`` covers the deprecation log level. If not, adjust
108+
it accordingly.
109+
110+
.. literalinclude:: errors/013.php
111+
112+
After that, subsequent deprecations will be logged instead of thrown.
113+
114+
This feature also works with user deprecations:
115+
116+
.. literalinclude:: errors/014.php
117+
118+
For testing your application you may want to always throw on deprecations. You may configure this by
119+
setting the environment variable ``CODEIGNITER_SCREAM_DEPRECATIONS`` to a truthy value.
120+
90121
Framework Exceptions
91122
====================
92123

@@ -197,37 +228,6 @@ Since v4.3.0, you can specify the exit code for your Exception class to implemen
197228

198229
When an exception implementing ``HasExitCodeInterface`` is caught by CodeIgniter's exception handler, the code returned from the ``getExitCode()`` method will become the exit code.
199230

200-
.. _logging_deprecation_warnings:
201-
202-
Logging Deprecation Warnings
203-
============================
204-
205-
.. versionadded:: 4.3.0
206-
207-
By default, all errors reported by ``error_reporting()`` will be thrown as an ``ErrorException`` object. These
208-
include both ``E_DEPRECATED`` and ``E_USER_DEPRECATED`` errors. With the surge in use of PHP 8.1+, many users
209-
may see exceptions thrown for `passing null to non-nullable arguments of internal functions <https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg>`_.
210-
To ease the migration to PHP 8.1, you can instruct CodeIgniter to log the deprecations instead of throwing them.
211-
212-
First, make sure your copy of ``Config\Exceptions`` is updated with the two new properties and set as follows:
213-
214-
.. literalinclude:: errors/012.php
215-
216-
Next, depending on the log level you set in ``Config\Exceptions::$deprecationLogLevel``, check whether the
217-
logger threshold defined in ``Config\Logger::$threshold`` covers the deprecation log level. If not, adjust
218-
it accordingly.
219-
220-
.. literalinclude:: errors/013.php
221-
222-
After that, subsequent deprecations will be logged instead of thrown.
223-
224-
This feature also works with user deprecations:
225-
226-
.. literalinclude:: errors/014.php
227-
228-
For testing your application you may want to always throw on deprecations. You may configure this by
229-
setting the environment variable ``CODEIGNITER_SCREAM_DEPRECATIONS`` to a truthy value.
230-
231231
.. _custom-exception-handlers:
232232

233233
Custom Exception Handlers

0 commit comments

Comments
 (0)