From 2d472f46777eacd24211a8f4d37af47eea78f89c Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:53:33 +1300 Subject: [PATCH 1/2] FIX Don't log to the error handler (#11523) --- _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; } From 06240b62fa3681707139b66c18cbcad182bbcd82 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Tue, 7 Jan 2025 13:48:52 +1300 Subject: [PATCH 2/2] API Deprecate API which will be removed in CMS 6 (#11526) --- src/Control/Director.php | 3 +++ src/Control/HTTPApplication.php | 5 ++++- .../URLSpecialsMiddleware/SessionEnvTypeSwitcher.php | 1 + src/Core/Manifest/VersionProvider.php | 2 ++ src/i18n/Messages/Symfony/FlushInvalidatedResource.php | 6 +++++- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Control/Director.php b/src/Control/Director.php index 119d4e746d0..12f2ac20974 100644 --- a/src/Control/Director.php +++ b/src/Control/Director.php @@ -12,6 +12,7 @@ use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Kernel; use SilverStripe\Core\Path; +use SilverStripe\Dev\Deprecation; use SilverStripe\Versioned\Versioned; use SilverStripe\View\Requirements; use SilverStripe\View\Requirements_Backend; @@ -1037,9 +1038,11 @@ public static function get_environment_type() * @param HTTPRequest $request * * @return string|null null if not overridden, otherwise the actual value + * @deprecated 5.4.0 Use get_environment_type() instead. */ public static function get_session_environment_type(HTTPRequest $request = null) { + Deprecation::notice('5.4.0', 'Use get_environment_type() instead.'); $request = static::currentRequest($request); if (!$request) { diff --git a/src/Control/HTTPApplication.php b/src/Control/HTTPApplication.php index b5bbd142f7c..ed3baffa91e 100644 --- a/src/Control/HTTPApplication.php +++ b/src/Control/HTTPApplication.php @@ -12,6 +12,7 @@ use SilverStripe\Core\Startup\RequestFlushDiscoverer; use SilverStripe\Core\Startup\ScheduledFlushDiscoverer; use SilverStripe\Core\Startup\DeployFlushDiscoverer; +use SilverStripe\Dev\Deprecation; class HTTPApplication implements Application { @@ -165,6 +166,8 @@ public function execute(HTTPRequest $request, callable $callback, $flush = false */ private function warnAboutDeprecatedSetups() { - // noop + if (defined('CUSTOM_INCLUDE_PATH')) { + Deprecation::notice('5.4.0', 'Use of the "CUSTOM_INCLUDE_PATH" constant is deprecated.', Deprecation::SCOPE_GLOBAL); + } } } diff --git a/src/Control/Middleware/URLSpecialsMiddleware/SessionEnvTypeSwitcher.php b/src/Control/Middleware/URLSpecialsMiddleware/SessionEnvTypeSwitcher.php index a3f7be39d69..ee3ed456460 100644 --- a/src/Control/Middleware/URLSpecialsMiddleware/SessionEnvTypeSwitcher.php +++ b/src/Control/Middleware/URLSpecialsMiddleware/SessionEnvTypeSwitcher.php @@ -8,6 +8,7 @@ /** * Implements switching user session into Test and Dev environment types + * @deprecated 5.4.0 Will be removed without equivalent functionality to replace it. */ trait SessionEnvTypeSwitcher { diff --git a/src/Core/Manifest/VersionProvider.php b/src/Core/Manifest/VersionProvider.php index b3477a3ba05..a951c0c9966 100644 --- a/src/Core/Manifest/VersionProvider.php +++ b/src/Core/Manifest/VersionProvider.php @@ -239,9 +239,11 @@ protected function getComposerLock($cache = true) /** * @return string + * @deprecated 5.4.0 Will be removed without equivalent functionality to replace it. */ protected function getComposerLockPath(): string { + Deprecation::noticeWithNoReplacment('5.4.0'); return BASE_PATH . '/composer.lock'; } } diff --git a/src/i18n/Messages/Symfony/FlushInvalidatedResource.php b/src/i18n/Messages/Symfony/FlushInvalidatedResource.php index 8ffa478f4c9..a24de272935 100644 --- a/src/i18n/Messages/Symfony/FlushInvalidatedResource.php +++ b/src/i18n/Messages/Symfony/FlushInvalidatedResource.php @@ -3,6 +3,7 @@ namespace SilverStripe\i18n\Messages\Symfony; use SilverStripe\Core\Flushable; +use SilverStripe\Dev\Deprecation; use Symfony\Component\Config\Resource\SelfCheckingResourceInterface; /** @@ -20,9 +21,12 @@ public function __toString() return md5(__CLASS__); } + /** + * @deprecated 5.4.0 Will be removed without equivalent functionality to replace it. + */ public function getResource() { - // @deprecated at 3.0, do nothing + Deprecation::noticeWithNoReplacment('5.4.0'); return null; }