MDL-83334 core: Remove deprecated constant E_STRICT

One of the error levels PHP previously emitted was E_STRICT, on code
that was not strictly correct to ensure interoperability and forward
compatibility. PHP 7.0 converted the majority of existing E_STRICT
warnings to E_NOTICE, and since PHP 8.0, all E_STRICT notices have
changed to E_NOTICE.

Because all of the E_STRICT notices are upgraded to E_NOTICE since PHP
8.0, PHP 8.4 deprecates the E_STRICT constant.

The E_STRICT constant is deprecated in PHP 8.4. Using the constant
anywhere in PHP code now emits a deprecation notice in PHP 8.4 and
later.

The E_STRICT constant will be removed in PHP 9.0.

PHP core and core extensions since PHP 8.0 and later do not emit
E_STRICT notices at all. It is safe to assume that any PHP applications
that run on PHP 8.0 and later will never encounter E_STRICT notices, and
error reporting and handling can be safely updated to ignore E_STRICT
notices.

See: https://php.watch/versions/8.4/E_STRICT-deprecated

Signed-off-by: Daniel Ziegenberg <[email protected]>
This commit is contained in:
Daniel Ziegenberg
2025-03-04 20:38:04 +01:00
parent 5670447ece
commit c23d5edb0f
19 changed files with 34 additions and 33 deletions
+4 -4
View File
@@ -430,7 +430,7 @@ if (isset($CFG->debug)) {
} else {
$CFG->debug = 0;
}
$CFG->debugdeveloper = (($CFG->debug & (E_ALL | E_STRICT)) === (E_ALL | E_STRICT)); // DEBUG_DEVELOPER is not available yet.
$CFG->debugdeveloper = (($CFG->debug & E_ALL) === E_ALL); // DEBUG_DEVELOPER is not available yet.
if (!defined('MOODLE_INTERNAL')) { // Necessary because cli installer has to define it earlier.
/** Used by library scripts to check they are being called by Moodle. */
@@ -651,14 +651,14 @@ $OUTPUT = new bootstrap_renderer();
// Set handler for uncaught exceptions - equivalent to throw new \moodle_exception() call.
if (!PHPUNIT_TEST or PHPUNIT_UTIL) {
set_exception_handler('default_exception_handler');
set_error_handler('default_error_handler', E_ALL | E_STRICT);
set_error_handler('default_error_handler', E_ALL);
}
// Acceptance tests needs special output to capture the errors,
// but not necessary for behat CLI command and init script.
if (defined('BEHAT_SITE_RUNNING') && !defined('BEHAT_TEST') && !defined('BEHAT_UTIL')) {
require_once(__DIR__ . '/behat/lib.php');
set_error_handler('behat_error_handler', E_ALL | E_STRICT);
set_error_handler('behat_error_handler', E_ALL);
}
if (defined('WS_SERVER') && WS_SERVER) {
@@ -667,7 +667,7 @@ if (defined('WS_SERVER') && WS_SERVER) {
}
// If there are any errors in the standard libraries we want to know!
error_reporting(E_ALL | E_STRICT);
error_reporting(E_ALL);
// Just say no to link prefetching (Moz prefetching, Google Web Accelerator, others)
// http://www.google.com/webmasters/faq.html#prefetchblock