diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 72f9c7f76f95..ed77d1417b47 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -105,7 +105,7 @@ public static function collectDeprecations($outputFile) $filesStack[] = $frame['file']; } - $deprecations[] = [error_reporting(), $msg, $file, $filesStack]; + $deprecations[] = [error_reporting() & $type, $msg, $file, $filesStack]; return null; }); @@ -135,7 +135,7 @@ public function handleError($type, $msg, $file, $line, $context = []) $method = $deprecation->originatingMethod(); $msg = $deprecation->getMessage(); - if (0 !== error_reporting()) { + if (error_reporting() & $type) { $group = 'unsilenced'; } elseif ($deprecation->isLegacy()) { $group = 'legacy'; diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 00433b16b7ee..0cb37c0743ac 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -320,7 +320,7 @@ public static function handleError($type, $msg, $file, $line, $context = []) if (\is_array($parsedMsg)) { $msg = $parsedMsg['deprecation']; } - if (error_reporting()) { + if (error_reporting() & $type) { $msg = 'Unsilenced deprecation: '.$msg; } self::$gatheredDeprecations[] = $msg; diff --git a/src/Symfony/Component/HttpKernel/Log/Logger.php b/src/Symfony/Component/HttpKernel/Log/Logger.php index e3badc3676e6..1e6308d6e0ed 100644 --- a/src/Symfony/Component/HttpKernel/Log/Logger.php +++ b/src/Symfony/Component/HttpKernel/Log/Logger.php @@ -37,10 +37,10 @@ class Logger extends AbstractLogger private $formatter; private $handle; - public function __construct(string $minLevel = null, $output = 'php://stderr', callable $formatter = null) + public function __construct(string $minLevel = null, $output = null, callable $formatter = null) { if (null === $minLevel) { - $minLevel = 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::CRITICAL : LogLevel::WARNING; + $minLevel = null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING; if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) { switch ((int) (isset($_ENV['SHELL_VERBOSITY']) ? $_ENV['SHELL_VERBOSITY'] : $_SERVER['SHELL_VERBOSITY'])) { @@ -58,7 +58,7 @@ public function __construct(string $minLevel = null, $output = 'php://stderr', c $this->minLevelIndex = self::$levels[$minLevel]; $this->formatter = $formatter ?: [$this, 'format']; - if (false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) { + if ($output && false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) { throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output)); } } @@ -79,10 +79,14 @@ public function log($level, $message, array $context = []) } $formatter = $this->formatter; - @fwrite($this->handle, $formatter($level, $message, $context)); + if ($this->handle) { + @fwrite($this->handle, $formatter($level, $message, $context)); + } else { + error_log($formatter($level, $message, $context, false)); + } } - private function format(string $level, string $message, array $context): string + private function format(string $level, string $message, array $context, bool $prefixDate = true): string { if (false !== strpos($message, '{')) { $replacements = []; @@ -101,6 +105,11 @@ private function format(string $level, string $message, array $context): string $message = strtr($message, $replacements); } - return sprintf('%s [%s] %s', date(\DateTime::RFC3339), $level, $message).PHP_EOL; + $log = sprintf('[%s] %s', $level, $message).PHP_EOL; + if ($prefixDate) { + $log = date(\DateTime::RFC3339).' '.$log; + } + + return $log; } } diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php index 8c658060ad4a..db94766d3f16 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php @@ -68,6 +68,7 @@ public function __serialize(): array public function __unserialize(array $data): void { [$this->secret, $parentData] = $data; + $parentData = \is_array($parentData) ? $parentData : unserialize($parentData); parent::__unserialize($parentData); } } diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php index eb20f7fe6bbd..80ac0fff38df 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php @@ -26,7 +26,6 @@ class PreAuthenticatedToken extends AbstractToken /** * @param string|\Stringable|UserInterface $user * @param mixed $credentials - * @param string $providerKey * @param string[] $roles */ public function __construct($user, $credentials, string $providerKey, array $roles = []) @@ -88,6 +87,7 @@ public function __serialize(): array public function __unserialize(array $data): void { [$this->credentials, $this->providerKey, $parentData] = $data; + $parentData = \is_array($parentData) ? $parentData : unserialize($parentData); parent::__unserialize($parentData); } } diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php index a41c7ef5d5e7..15925e6252de 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php @@ -101,6 +101,7 @@ public function __serialize(): array public function __unserialize(array $data): void { [$this->secret, $this->providerKey, $parentData] = $data; + $parentData = \is_array($parentData) ? $parentData : unserialize($parentData); parent::__unserialize($parentData); } } diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/SwitchUserToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/SwitchUserToken.php index 4177cee658f6..4390d68a6e5c 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/SwitchUserToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/SwitchUserToken.php @@ -54,6 +54,7 @@ public function __serialize(): array public function __unserialize(array $data): void { [$this->originalToken, $parentData] = $data; + $parentData = \is_array($parentData) ? $parentData : unserialize($parentData); parent::__unserialize($parentData); } } diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php index eefe75d2d3ae..f9a4a5d4e202 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php @@ -99,6 +99,7 @@ public function __serialize(): array public function __unserialize(array $data): void { [$this->credentials, $this->providerKey, $parentData] = $data; + $parentData = \is_array($parentData) ? $parentData : unserialize($parentData); parent::__unserialize($parentData); } } diff --git a/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php b/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php index f3fa661c31f4..1b4e818a1157 100644 --- a/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php +++ b/src/Symfony/Component/Security/Core/Exception/AccountStatusException.php @@ -53,6 +53,7 @@ public function __serialize(): array public function __unserialize(array $data): void { [$this->user, $parentData] = $data; + $parentData = \is_array($parentData) ? $parentData : unserialize($parentData); parent::__unserialize($parentData); } } diff --git a/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php index 324658a44335..799d7e0caf37 100644 --- a/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php +++ b/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php @@ -69,6 +69,7 @@ public function __serialize(): array public function __unserialize(array $data): void { [$parentData, $this->messageKey, $this->messageData] = $data; + $parentData = \is_array($parentData) ? $parentData : unserialize($parentData); parent::__unserialize($parentData); } } diff --git a/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php b/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php index e1f816bc6b09..f46013236c12 100644 --- a/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php +++ b/src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php @@ -69,6 +69,7 @@ public function __serialize(): array public function __unserialize(array $data): void { [$this->username, $parentData] = $data; + $parentData = \is_array($parentData) ? $parentData : unserialize($parentData); parent::__unserialize($parentData); } } diff --git a/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php b/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php index 1c58199c5b0f..511f455531ec 100644 --- a/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php +++ b/src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php @@ -83,6 +83,7 @@ public function __serialize(): array public function __unserialize(array $data): void { [$this->providerKey, $parentData] = $data; + $parentData = \is_array($parentData) ? $parentData : unserialize($parentData); parent::__unserialize($parentData); } }