From 3c1197e10c543eb22bcff4e573871be9c08a5bce Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Sun, 5 Jan 2025 17:51:49 +1300 Subject: [PATCH] FIX Don't log to the error handler --- _config/logging.yml | 8 +++++--- src/Security/Member.php | 2 +- src/Security/MemberAuthenticator/LostPasswordHandler.php | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/_config/logging.yml b/_config/logging.yml index b729fd33710..e2e7d96c3dc 100644 --- a/_config/logging.yml +++ b/_config/logging.yml @@ -16,14 +16,16 @@ SilverStripe\Core\Injector\Injector: pushDefaultLogger: [ pushLogger, [ '%$Psr\Log\LoggerInterface' ] ] pushErrorHandler: [ pushLogger, [ '%$Psr\Log\LoggerInterface.errorhandler' ] ] - # Default implementation for use as a standard logger. Up to developers to attach their own - # handlers + # Default implementation for use as a standard logger. Used for logging custom messages. + # Projects should attach log handlers to this logging service. Psr\Log\LoggerInterface: type: singleton class: Monolog\Logger constructor: - "error-log" - # Core error handling + # Core error handling - only uncaught exceptions and PHP errors should be caught by this handler. + # This handler displays those errors in the browser and CLI. + # Projects should not attach log handlers to this error handler service. Psr\Log\LoggerInterface.errorhandler: type: singleton class: Monolog\Logger diff --git a/src/Security/Member.php b/src/Security/Member.php index a3c3dc0d7f4..6542c57933a 100644 --- a/src/Security/Member.php +++ b/src/Security/Member.php @@ -808,7 +808,7 @@ public function onBeforeWrite() $email->send(); } catch (TransportExceptionInterface | RfcComplianceException $e) { /** @var LoggerInterface $logger */ - $logger = Injector::inst()->get(LoggerInterface::class . '.errorhandler'); + $logger = Injector::inst()->get(LoggerInterface::class); $logger->error('Error sending email in ' . __FILE__ . ' line ' . __LINE__ . ": {$e->getMessage()}"); } } diff --git a/src/Security/MemberAuthenticator/LostPasswordHandler.php b/src/Security/MemberAuthenticator/LostPasswordHandler.php index 41d3718b210..1727f6f23f0 100644 --- a/src/Security/MemberAuthenticator/LostPasswordHandler.php +++ b/src/Security/MemberAuthenticator/LostPasswordHandler.php @@ -256,7 +256,7 @@ protected function sendEmail($member, $token) return true; } catch (TransportExceptionInterface | RfcComplianceException $e) { /** @var LoggerInterface $logger */ - $logger = Injector::inst()->get(LoggerInterface::class . '.errorhandler'); + $logger = Injector::inst()->get(LoggerInterface::class); $logger->error('Error sending email in ' . __FILE__ . ' line ' . __LINE__ . ": {$e->getMessage()}"); return false; }