mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Prevent infinite loops in Deprecation::notice()
This commit is contained in:
parent
906cd0e76d
commit
1ee0aff1d1
@ -67,6 +67,8 @@ class Deprecation
|
||||
*/
|
||||
protected static $module_version_overrides = [];
|
||||
|
||||
protected static bool $inside_notice = false;
|
||||
|
||||
/**
|
||||
* @var int - the notice level to raise on a deprecation notice. Defaults to E_USER_DEPRECATED if that exists,
|
||||
* E_USER_NOTICE if not
|
||||
@ -171,10 +173,16 @@ class Deprecation
|
||||
*/
|
||||
public static function notice($atVersion, $string = '', $scope = Deprecation::SCOPE_METHOD)
|
||||
{
|
||||
if (static::$inside_notice) {
|
||||
return;
|
||||
}
|
||||
static::$inside_notice = true;
|
||||
// try block needs to wrap all code in case anything inside the try block
|
||||
// calls something else that calls Deprecation::notice()
|
||||
try {
|
||||
if (!static::get_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$checkVersion = self::$version;
|
||||
// Getting a backtrace is slow, so we only do it if we need it
|
||||
$backtrace = null;
|
||||
@ -238,6 +246,9 @@ class Deprecation
|
||||
user_error($string ?? '', $level ?? 0);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
static::$inside_notice = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user