Skip to content

Commit 5e3bd31

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [Notifier] fix firebase error handling so the transports doesn't try setting the success message, that doesn't exists. Remove wrong dep [Translation] Fix message key handling for the Localise provider [Serializer] Deprecate support for returning empty, iterable, countable, raw object when normalizing Fix ProgressBar to correctly clear multi-line formats [Mailer] Consume a PSR-14 event dispatcher Ignoring X-Transport header while signing email with DKIM Remove polyfills from ExpressionLanguage Update validators.tr.xlf [Form] fix typo in Danish translation [HttpKernel] Fix timestamp_rfc3339 in LoggerDataCollector Remove broken test case [PropertyInfo] Support for the never return type Show nice CLI output in Psalm action add more explicit error Signed-off-by: Alexander M. Turek <me@derrabus.de>
2 parents 68a5e3e + 6366d6f commit 5e3bd31

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

DataCollector/LoggerDataCollector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ private function getContainerDeprecationLogs(): array
208208
$logs = [];
209209
foreach (unserialize($logContent) as $log) {
210210
$log['context'] = ['exception' => new SilencedErrorContext($log['type'], $log['file'], $log['line'], $log['trace'], $log['count'])];
211-
$log['timestamp'] = (new \DateTimeImmutable())->setTimestamp($bootTime)->format(\DateTimeInterface::RFC3339_EXTENDED);
211+
$log['timestamp'] = $bootTime;
212+
$log['timestamp_rfc3339'] = (new \DateTimeImmutable())->setTimestamp($bootTime)->format(\DateTimeInterface::RFC3339_EXTENDED);
212213
$log['priority'] = 100;
213214
$log['priorityName'] = 'DEBUG';
214215
$log['channel'] = null;

Tests/DataCollector/LoggerDataCollectorTest.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\HttpFoundation\Response;
1919
use Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector;
2020
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
21+
use Symfony\Component\VarDumper\Cloner\Data;
2122

2223
class LoggerDataCollectorTest extends TestCase
2324
{
@@ -45,6 +46,52 @@ public function testCollectWithUnexpectedFormat()
4546
], $compilerLogs['Unknown Compiler Pass']);
4647
}
4748

49+
public function testCollectFromDeprecationsLog()
50+
{
51+
$containerPathPrefix = __DIR__.'/';
52+
$path = $containerPathPrefix.'Deprecations.log';
53+
touch($path);
54+
file_put_contents($path, serialize([[
55+
'type' => 16384,
56+
'message' => 'The "Symfony\Bundle\FrameworkBundle\Controller\Controller" class is deprecated since Symfony 4.2, use Symfony\Bundle\FrameworkBundle\Controller\AbstractController instead.',
57+
'file' => '/home/hamza/projet/contrib/sf/vendor/symfony/framework-bundle/Controller/Controller.php',
58+
'line' => 17,
59+
'trace' => [[
60+
'file' => '/home/hamza/projet/contrib/sf/src/Controller/DefaultController.php',
61+
'line' => 9,
62+
'function' => 'spl_autoload_call',
63+
]],
64+
'count' => 1,
65+
]]));
66+
67+
$logger = $this
68+
->getMockBuilder(DebugLoggerInterface::class)
69+
->setMethods(['countErrors', 'getLogs', 'clear'])
70+
->getMock();
71+
72+
$logger->expects($this->once())->method('countErrors')->willReturn(0);
73+
$logger->expects($this->exactly(2))->method('getLogs')->willReturn([]);
74+
75+
$c = new LoggerDataCollector($logger, $containerPathPrefix);
76+
$c->lateCollect();
77+
78+
$processedLogs = $c->getProcessedLogs();
79+
80+
$this->assertCount(1, $processedLogs);
81+
82+
$this->assertEquals($processedLogs[0]['type'], 'deprecation');
83+
$this->assertEquals($processedLogs[0]['errorCounter'], 1);
84+
$this->assertEquals($processedLogs[0]['timestamp'], (new \DateTimeImmutable())->setTimestamp(filemtime($path))->format(\DateTimeInterface::RFC3339_EXTENDED));
85+
$this->assertEquals($processedLogs[0]['priority'], 100);
86+
$this->assertEquals($processedLogs[0]['priorityName'], 'DEBUG');
87+
$this->assertNull($processedLogs[0]['channel']);
88+
89+
$this->assertInstanceOf(Data::class, $processedLogs[0]['message']);
90+
$this->assertInstanceOf(Data::class, $processedLogs[0]['context']);
91+
92+
@unlink($path);
93+
}
94+
4895
public function testWithMainRequest()
4996
{
5097
$mainRequest = new Request();

0 commit comments

Comments
 (0)