Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b1c7383

Browse filesBrowse files
Merge branch '5.1'
* 5.1: [PhpUnitBridge] fix bad detection of unsilenced deprecations [Security] Unserialize $parentData, if needed, to avoid errors [HttpKernel] Fix error logger when stderr is redirected to /dev/null (FPM)
2 parents 5fb5082 + b923991 commit b1c7383
Copy full SHA for b1c7383
Expand file treeCollapse file tree

12 files changed

+27
-10
lines changed

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function collectDeprecations($outputFile)
105105
$filesStack[] = $frame['file'];
106106
}
107107

108-
$deprecations[] = [error_reporting(), $msg, $file, $filesStack];
108+
$deprecations[] = [error_reporting() & $type, $msg, $file, $filesStack];
109109

110110
return null;
111111
});
@@ -135,7 +135,7 @@ public function handleError($type, $msg, $file, $line, $context = [])
135135
$method = $deprecation->originatingMethod();
136136
$msg = $deprecation->getMessage();
137137

138-
if (0 !== error_reporting()) {
138+
if (error_reporting() & $type) {
139139
$group = 'unsilenced';
140140
} elseif ($deprecation->isLegacy()) {
141141
$group = 'legacy';

‎src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public static function handleError($type, $msg, $file, $line, $context = [])
320320
if (\is_array($parsedMsg)) {
321321
$msg = $parsedMsg['deprecation'];
322322
}
323-
if (error_reporting()) {
323+
if (error_reporting() & $type) {
324324
$msg = 'Unsilenced deprecation: '.$msg;
325325
}
326326
self::$gatheredDeprecations[] = $msg;

‎src/Symfony/Component/HttpKernel/Log/Logger.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Log/Logger.php
+15-6Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class Logger extends AbstractLogger
3737
private $formatter;
3838
private $handle;
3939

40-
public function __construct(string $minLevel = null, $output = 'php://stderr', callable $formatter = null)
40+
public function __construct(string $minLevel = null, $output = null, callable $formatter = null)
4141
{
4242
if (null === $minLevel) {
43-
$minLevel = 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::CRITICAL : LogLevel::WARNING;
43+
$minLevel = null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING;
4444

4545
if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) {
4646
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
5858

5959
$this->minLevelIndex = self::$levels[$minLevel];
6060
$this->formatter = $formatter ?: [$this, 'format'];
61-
if (false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) {
61+
if ($output && false === $this->handle = \is_resource($output) ? $output : @fopen($output, 'a')) {
6262
throw new InvalidArgumentException(sprintf('Unable to open "%s".', $output));
6363
}
6464
}
@@ -79,10 +79,14 @@ public function log($level, $message, array $context = [])
7979
}
8080

8181
$formatter = $this->formatter;
82-
@fwrite($this->handle, $formatter($level, $message, $context));
82+
if ($this->handle) {
83+
@fwrite($this->handle, $formatter($level, $message, $context));
84+
} else {
85+
error_log($formatter($level, $message, $context, false));
86+
}
8387
}
8488

85-
private function format(string $level, string $message, array $context): string
89+
private function format(string $level, string $message, array $context, bool $prefixDate = true): string
8690
{
8791
if (false !== strpos($message, '{')) {
8892
$replacements = [];
@@ -101,6 +105,11 @@ private function format(string $level, string $message, array $context): string
101105
$message = strtr($message, $replacements);
102106
}
103107

104-
return sprintf('%s [%s] %s', date(\DateTime::RFC3339), $level, $message).PHP_EOL;
108+
$log = sprintf('[%s] %s', $level, $message).PHP_EOL;
109+
if ($prefixDate) {
110+
$log = date(\DateTime::RFC3339).' '.$log;
111+
}
112+
113+
return $log;
105114
}
106115
}

‎src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function __serialize(): array
6868
public function __unserialize(array $data): void
6969
{
7070
[$this->secret, $parentData] = $data;
71+
$parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
7172
parent::__unserialize($parentData);
7273
}
7374
}

‎src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class PreAuthenticatedToken extends AbstractToken
2626
/**
2727
* @param string|\Stringable|UserInterface $user
2828
* @param mixed $credentials
29-
* @param string $providerKey
3029
* @param string[] $roles
3130
*/
3231
public function __construct($user, $credentials, string $providerKey, array $roles = [])
@@ -88,6 +87,7 @@ public function __serialize(): array
8887
public function __unserialize(array $data): void
8988
{
9089
[$this->credentials, $this->providerKey, $parentData] = $data;
90+
$parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
9191
parent::__unserialize($parentData);
9292
}
9393
}

‎src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public function __serialize(): array
101101
public function __unserialize(array $data): void
102102
{
103103
[$this->secret, $this->providerKey, $parentData] = $data;
104+
$parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
104105
parent::__unserialize($parentData);
105106
}
106107
}

‎src/Symfony/Component/Security/Core/Authentication/Token/SwitchUserToken.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authentication/Token/SwitchUserToken.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function __serialize(): array
5454
public function __unserialize(array $data): void
5555
{
5656
[$this->originalToken, $parentData] = $data;
57+
$parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
5758
parent::__unserialize($parentData);
5859
}
5960
}

‎src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public function __serialize(): array
9999
public function __unserialize(array $data): void
100100
{
101101
[$this->credentials, $this->providerKey, $parentData] = $data;
102+
$parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
102103
parent::__unserialize($parentData);
103104
}
104105
}

‎src/Symfony/Component/Security/Core/Exception/AccountStatusException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Exception/AccountStatusException.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function __serialize(): array
5353
public function __unserialize(array $data): void
5454
{
5555
[$this->user, $parentData] = $data;
56+
$parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
5657
parent::__unserialize($parentData);
5758
}
5859
}

‎src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function __serialize(): array
6969
public function __unserialize(array $data): void
7070
{
7171
[$parentData, $this->messageKey, $this->messageData] = $data;
72+
$parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
7273
parent::__unserialize($parentData);
7374
}
7475
}

‎src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function __serialize(): array
6969
public function __unserialize(array $data): void
7070
{
7171
[$this->username, $parentData] = $data;
72+
$parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
7273
parent::__unserialize($parentData);
7374
}
7475
}

‎src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Guard/Token/PostAuthenticationGuardToken.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function __serialize(): array
8383
public function __unserialize(array $data): void
8484
{
8585
[$this->providerKey, $parentData] = $data;
86+
$parentData = \is_array($parentData) ? $parentData : unserialize($parentData);
8687
parent::__unserialize($parentData);
8788
}
8889
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.