mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Correctly identify deprecated API in withNoReplacement (#10706)
This commit is contained in:
parent
ab566b0a15
commit
652281507f
@ -177,6 +177,12 @@ class Deprecation
|
|||||||
$level = 1;
|
$level = 1;
|
||||||
}
|
}
|
||||||
$newLevel = $level;
|
$newLevel = $level;
|
||||||
|
// handle closures inside withNoReplacement()
|
||||||
|
if (self::$insideWithNoReplacement
|
||||||
|
&& substr($backtrace[$newLevel]['function'], -strlen('{closure}')) === '{closure}'
|
||||||
|
) {
|
||||||
|
$newLevel = $newLevel + 2;
|
||||||
|
}
|
||||||
// handle call_user_func
|
// handle call_user_func
|
||||||
if ($level === 4 && strpos($backtrace[2]['function'] ?? '', 'call_user_func') !== false) {
|
if ($level === 4 && strpos($backtrace[2]['function'] ?? '', 'call_user_func') !== false) {
|
||||||
$newLevel = 5;
|
$newLevel = 5;
|
||||||
|
@ -151,6 +151,22 @@ class DeprecationTest extends SapphireTest
|
|||||||
Deprecation::outputNotices();
|
Deprecation::outputNotices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNoticeWithNoReplacementTrue()
|
||||||
|
{
|
||||||
|
$message = implode(' ', [
|
||||||
|
'SilverStripe\Dev\Tests\DeprecationTest->testNoticeWithNoReplacementTrue is deprecated.',
|
||||||
|
'My message.',
|
||||||
|
'Called from PHPUnit\Framework\TestCase->runTest.'
|
||||||
|
]);
|
||||||
|
$this->expectDeprecation();
|
||||||
|
$this->expectDeprecationMessage($message);
|
||||||
|
Deprecation::enable(true);
|
||||||
|
Deprecation::withNoReplacement(function () {
|
||||||
|
Deprecation::notice('123', 'My message.');
|
||||||
|
});
|
||||||
|
Deprecation::outputNotices();
|
||||||
|
}
|
||||||
|
|
||||||
public function testClassWithNoReplacement()
|
public function testClassWithNoReplacement()
|
||||||
{
|
{
|
||||||
$message = implode(' ', [
|
$message = implode(' ', [
|
||||||
|
Loading…
Reference in New Issue
Block a user