Fix #16256 - Warning: error_reporting() has been disabled for security reasons on php 7.x
Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
parent
a2fb692d91
commit
0e344b6a50
@ -779,7 +779,7 @@ class Config
|
||||
$this->error_config_default_file = true;
|
||||
return false;
|
||||
}
|
||||
$canUseErrorReporting = function_exists('error_reporting');
|
||||
$canUseErrorReporting = Util::isErrorReportingAvailable();
|
||||
$oldErrorReporting = null;
|
||||
if ($canUseErrorReporting) {
|
||||
$oldErrorReporting = error_reporting(0);
|
||||
@ -837,7 +837,7 @@ class Config
|
||||
* Parses the configuration file, we throw away any errors or
|
||||
* output.
|
||||
*/
|
||||
$canUseErrorReporting = function_exists('error_reporting');
|
||||
$canUseErrorReporting = Util::isErrorReportingAvailable();
|
||||
$oldErrorReporting = null;
|
||||
if ($canUseErrorReporting) {
|
||||
$oldErrorReporting = error_reporting(0);
|
||||
|
||||
@ -52,7 +52,7 @@ class ErrorHandler
|
||||
if (! defined('TESTSUITE')) {
|
||||
set_error_handler([$this, 'handleError']);
|
||||
}
|
||||
if (function_exists('error_reporting')) {
|
||||
if (Util::isErrorReportingAvailable()) {
|
||||
$this->error_reporting = error_reporting();
|
||||
}
|
||||
}
|
||||
@ -165,7 +165,7 @@ class ErrorHandler
|
||||
string $errfile,
|
||||
int $errline
|
||||
): void {
|
||||
if (function_exists('error_reporting')) {
|
||||
if (Util::isErrorReportingAvailable()) {
|
||||
/**
|
||||
* Check if Error Control Operator (@) was used, but still show
|
||||
* user errors even in this case.
|
||||
|
||||
@ -4997,4 +4997,24 @@ class Util
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if error reporting is available
|
||||
* @return bool
|
||||
*/
|
||||
public static function isErrorReportingAvailable(): bool
|
||||
{
|
||||
// issue #16256 - PHP 7.x does not return false for a core function
|
||||
if (PHP_MAJOR_VERSION < 8) {
|
||||
$disabled = ini_get('disable_functions');
|
||||
if (is_string($disabled)) {
|
||||
$disabled = explode(',', $disabled);
|
||||
$disabled = array_map(function (string $part) {
|
||||
return trim($part);
|
||||
}, $disabled);
|
||||
return ! in_array('error_reporting', $disabled);
|
||||
}
|
||||
}
|
||||
return function_exists('error_reporting');
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,6 +34,7 @@ header('Content-Type: text/html; charset=utf-8');
|
||||
|
||||
require ROOT_PATH . 'libraries/vendor_config.php';
|
||||
|
||||
// issue #16256 - This only works with php 8.0+
|
||||
if (function_exists('error_reporting')) {
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user