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:
@@ -45,7 +45,7 @@ $CFG->admin = 'admin';
|
||||
$CFG->directorypermissions = 0777;
|
||||
|
||||
// Debug options - possible to be controlled by flag in future.
|
||||
$CFG->debug = (E_ALL | E_STRICT); // DEBUG_DEVELOPER.
|
||||
$CFG->debug = (E_ALL); // DEBUG_DEVELOPER.
|
||||
$CFG->debugdisplay = 1;
|
||||
$CFG->debugstringids = 1; // Add strings=1 to url to get string ids.
|
||||
$CFG->perfdebug = 15;
|
||||
|
||||
@@ -71,7 +71,7 @@ Example:
|
||||
exit(0);
|
||||
}
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
$content = core_component::get_cache_content();
|
||||
|
||||
@@ -166,7 +166,7 @@ $CFG->running_installer = true;
|
||||
$CFG->early_install_lang = true;
|
||||
$CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
|
||||
$CFG->dboptions = array();
|
||||
$CFG->debug = (E_ALL | E_STRICT);
|
||||
$CFG->debug = (E_ALL);
|
||||
$CFG->debugdisplay = true;
|
||||
$CFG->debugdeveloper = true;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ require_once(__DIR__.'/../../../../lib/behat/lib.php');
|
||||
require_once(__DIR__.'/../../../../lib/behat/classes/behat_command.php');
|
||||
require_once(__DIR__.'/../../../../lib/behat/classes/behat_config_manager.php');
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('log_errors', '1');
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ require_once(__DIR__ . '/../../../../lib/behat/classes/behat_command.php');
|
||||
require_once(__DIR__ . '/../../../../lib/behat/classes/behat_config_manager.php');
|
||||
|
||||
// Remove error handling overrides done in config.php. This is consistent with admin/tool/behat/cli/util_single_run.php.
|
||||
$CFG->debug = (E_ALL | E_STRICT);
|
||||
$CFG->debug = (E_ALL);
|
||||
$CFG->debugdisplay = 1;
|
||||
error_reporting($CFG->debug);
|
||||
ini_set('display_errors', '1');
|
||||
|
||||
@@ -117,7 +117,7 @@ define('ABORT_AFTER_CONFIG', true);
|
||||
require_once(__DIR__ . '/../../../../config.php');
|
||||
|
||||
// Remove error handling overrides done in config.php.
|
||||
$CFG->debug = (E_ALL | E_STRICT);
|
||||
$CFG->debug = (E_ALL);
|
||||
$CFG->debugdisplay = 1;
|
||||
error_reporting($CFG->debug);
|
||||
ini_set('display_errors', '1');
|
||||
|
||||
+2
-2
@@ -813,9 +813,9 @@ $CFG->admin = 'admin';
|
||||
//=========================================================================
|
||||
//
|
||||
// Force a debugging mode regardless the settings in the site administration
|
||||
// @error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS!
|
||||
// @error_reporting(E_ALL); // NOT FOR PRODUCTION SERVERS!
|
||||
// @ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS!
|
||||
// $CFG->debug = (E_ALL | E_STRICT); // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS!
|
||||
// $CFG->debug = (E_ALL); // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS!
|
||||
// $CFG->debugdisplay = 1; // NOT FOR PRODUCTION SERVERS!
|
||||
//
|
||||
// Display exceptions using the 'pretty' Whoops! utility.
|
||||
|
||||
+1
-1
@@ -181,7 +181,7 @@ $CFG->umaskpermissions = (($CFG->directorypermissions & 0777) ^ 0777);
|
||||
$CFG->running_installer = true;
|
||||
$CFG->early_install_lang = true;
|
||||
$CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
|
||||
$CFG->debug = (E_ALL | E_STRICT);
|
||||
$CFG->debug = (E_ALL);
|
||||
$CFG->debugdisplay = true;
|
||||
$CFG->debugdeveloper = true;
|
||||
|
||||
|
||||
+2
-3
@@ -101,7 +101,6 @@ function behat_get_error_string($errtype) {
|
||||
break;
|
||||
case E_NOTICE:
|
||||
case E_USER_NOTICE:
|
||||
case E_STRICT:
|
||||
$errnostr = 'Notice';
|
||||
break;
|
||||
case E_RECOVERABLE_ERROR:
|
||||
@@ -133,11 +132,11 @@ function behat_error_handler($errno, $errstr, $errfile, $errline) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// This error handler receives E_ALL | E_STRICT, running the behat test site the debug level is
|
||||
// This error handler receives E_ALL, running the behat test site the debug level is
|
||||
// set to DEVELOPER and will always include E_NOTICE,E_USER_NOTICE... as part of E_ALL, if the current
|
||||
// error_reporting() value does not include one of those levels is because it has been forced through
|
||||
// the moodle code (see fix_utf8() for example) in that cases we respect the forced error level value.
|
||||
$respect = array(E_NOTICE, E_USER_NOTICE, E_STRICT, E_WARNING, E_USER_WARNING, E_DEPRECATED, E_USER_DEPRECATED);
|
||||
$respect = [E_NOTICE, E_USER_NOTICE, E_WARNING, E_USER_WARNING, E_DEPRECATED, E_USER_DEPRECATED];
|
||||
foreach ($respect as $respectable) {
|
||||
|
||||
// If the current value does not include this kind of errors and the reported error is
|
||||
|
||||
@@ -565,7 +565,7 @@ class component {
|
||||
/**
|
||||
* Are we in developer debug mode?
|
||||
*
|
||||
* Note: You need to set "$CFG->debug = (E_ALL | E_STRICT);" in config.php,
|
||||
* Note: You need to set "$CFG->debug = (E_ALL);" in config.php,
|
||||
* the reason is we need to use this before we setup DB connection or caches for CFG.
|
||||
*
|
||||
* @return bool
|
||||
@@ -580,7 +580,7 @@ class component {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($debug & E_ALL && $debug & E_STRICT) {
|
||||
if ($debug & E_ALL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -373,9 +373,9 @@ function install_cli_database(array $options, $interactive) {
|
||||
require_once($CFG->libdir.'/upgradelib.php');
|
||||
|
||||
// show as much debug as possible
|
||||
@error_reporting(E_ALL | E_STRICT);
|
||||
@error_reporting(E_ALL);
|
||||
@ini_set('display_errors', '1');
|
||||
$CFG->debug = (E_ALL | E_STRICT);
|
||||
$CFG->debug = (E_ALL);
|
||||
$CFG->debugdisplay = true;
|
||||
$CFG->debugdeveloper = true;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
}
|
||||
|
||||
// We want to know about all problems.
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('log_errors', '1');
|
||||
|
||||
@@ -91,7 +91,7 @@ if (!defined('PHPUNIT_LONGTEST')) {
|
||||
}
|
||||
|
||||
// Remove error handling overrides done in config.php.
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('log_errors', '1');
|
||||
set_time_limit(0); // No time limit in CLI scripts, user may cancel execution.
|
||||
@@ -217,7 +217,7 @@ unset($allowed);
|
||||
unset($productioncfg);
|
||||
|
||||
// Force the same CFG settings in all sites.
|
||||
$CFG->debug = (E_ALL | E_STRICT); // Can not use DEBUG_DEVELOPER yet.
|
||||
$CFG->debug = (E_ALL); // Can not use DEBUG_DEVELOPER yet.
|
||||
$CFG->debugdeveloper = true;
|
||||
$CFG->debugdisplay = 1;
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
@@ -27,3 +27,5 @@ Local changes:
|
||||
it has the patch, please ignore this note.
|
||||
* 2023-01-31 Applied patch https://github.com/gggeek/phpxmlrpc/pull/110. See MDL-76412 for more details.
|
||||
* readme_moodle.txt - this file ;-)
|
||||
* 2025/01/17 - Server.php has minor changes for PHP 8.4 compatibility. See https://github.com/gggeek/phpxmlrpc/pull/125 and
|
||||
MDL-83334 for more details.
|
||||
|
||||
@@ -1416,8 +1416,10 @@ class Server
|
||||
}
|
||||
|
||||
//if ($errCode != E_NOTICE && $errCode != E_WARNING && $errCode != E_USER_NOTICE && $errCode != E_USER_WARNING)
|
||||
if ($errCode != E_STRICT) {
|
||||
if (PHP_VERSION_ID >= 70400) {
|
||||
static::error_occurred($errString);
|
||||
} elseif ($errCode != E_STRICT) {
|
||||
static::error_occurred($errString);
|
||||
}
|
||||
|
||||
// Try to avoid as much as possible disruption to the previous error handling mechanism in place
|
||||
|
||||
+4
-4
@@ -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
|
||||
|
||||
+4
-4
@@ -34,10 +34,10 @@ define('DEBUG_NONE', 0);
|
||||
define('DEBUG_MINIMAL', E_ERROR | E_PARSE);
|
||||
/** Errors, warnings and notices */
|
||||
define('DEBUG_NORMAL', E_ERROR | E_PARSE | E_WARNING | E_NOTICE);
|
||||
/** All problems except strict PHP warnings */
|
||||
define('DEBUG_ALL', E_ALL & ~E_STRICT);
|
||||
/** DEBUG_ALL with all debug messages and strict warnings */
|
||||
define('DEBUG_DEVELOPER', E_ALL | E_STRICT);
|
||||
/** All problems. Formerly, all problems, except the erstwhile strict PHP warnings before E_STRICT got deprecated. */
|
||||
define('DEBUG_ALL', E_ALL);
|
||||
/** Same as DEBUG_ALL since E_STRICT was deprecated. */
|
||||
define('DEBUG_DEVELOPER', E_ALL);
|
||||
|
||||
/** Remove any memory limits */
|
||||
define('MEMORY_UNLIMITED', -1);
|
||||
|
||||
@@ -116,9 +116,9 @@ final class ajaxlib_test extends \advanced_testcase {
|
||||
}
|
||||
|
||||
public function test_output_capture_error_debug_all(): void {
|
||||
// In error conditions, and with DEBUG_ALL set, we should not receive any output or throw any exceptions.
|
||||
// In error conditions, and with DEBUG_ALL set, we should throw an exceptions.
|
||||
set_debugging(DEBUG_ALL);
|
||||
$this->helper_test_dirty_output();
|
||||
$this->helper_test_dirty_output(true);
|
||||
}
|
||||
|
||||
public function test_output_capture_error_debugdeveloper(): void {
|
||||
|
||||
@@ -538,7 +538,7 @@ final class weblib_test extends advanced_testcase {
|
||||
|
||||
set_debugging(DEBUG_ALL);
|
||||
$this->assertEquals(DEBUG_ALL, $CFG->debug);
|
||||
$this->assertFalse($CFG->debugdeveloper);
|
||||
$this->assertTrue($CFG->debugdeveloper);
|
||||
|
||||
set_debugging(DEBUG_NORMAL);
|
||||
$this->assertEquals(DEBUG_NORMAL, $CFG->debug);
|
||||
|
||||
@@ -3763,8 +3763,6 @@ abstract class lesson_base {
|
||||
return !empty($this->properties->{$key});
|
||||
}
|
||||
|
||||
//NOTE: E_STRICT does not allow to change function signature!
|
||||
|
||||
/**
|
||||
* If implemented should create a new instance, save it in the DB and return it
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user