diff --git a/src/Error/ErrorTrap.php b/src/Error/ErrorTrap.php index 12dedd94174..c1f743e8222 100644 --- a/src/Error/ErrorTrap.php +++ b/src/Error/ErrorTrap.php @@ -200,6 +200,12 @@ public function renderer(): ErrorRendererInterface */ public function logger(): ErrorLoggerInterface { + $oldConfig = $this->getConfig('errorLogger'); + if ($oldConfig !== null) { + deprecationWarning('The `errorLogger` configuration key is deprecated. Use `logger` instead.'); + $this->setConfig(['logger' => $oldConfig, 'errorLogger' => null]); + } + /** @var class-string<\Cake\Error\ErrorLoggerInterface> $class */ $class = $this->getConfig('logger', $this->_defaultConfig['logger']); if (!in_array(ErrorLoggerInterface::class, class_implements($class))) { diff --git a/tests/TestCase/Error/ErrorTrapTest.php b/tests/TestCase/Error/ErrorTrapTest.php index 8b43f851424..86cb7f870cc 100644 --- a/tests/TestCase/Error/ErrorTrapTest.php +++ b/tests/TestCase/Error/ErrorTrapTest.php @@ -82,6 +82,14 @@ public function testLoggerConfig() $this->assertInstanceOf(ErrorLogger::class, $trap->logger()); } + public function testLoggerConfigCompatibility() + { + $this->deprecated(function () { + $trap = new ErrorTrap(['errorLogger' => ErrorLogger::class]); + $this->assertInstanceOf(ErrorLogger::class, $trap->logger()); + }); + } + public function testLoggerHandleUnsafeOverwrite() { $trap = new ErrorTrap();