Skip to content

Commit 2301234

Browse files
committed
fix: DataCollector __wakeup changed to __unserialize in Symfony 8
1 parent ef11ccf commit 2301234

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
44

55
# Version 2
66

7+
# 2.3.1 - 2026-04-25
8+
9+
- Fix compatibility issue with Symfony 8.
10+
711
# 2.3.0 - 2025-01-05
812

913
- Compatibility with Symfony 8.

src/Collector/Collector.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Symfony\Component\HttpFoundation\Request;
88
use Symfony\Component\HttpFoundation\Response;
99
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
10+
use Symfony\Component\HttpKernel\Kernel;
1011

1112
/**
1213
* The Collector holds profiled Stacks pushed by the StackPlugin. It also has a list of the configured clients.
@@ -30,11 +31,28 @@ public function __construct(?int $capturedBodyLength = null)
3031
$this->reset();
3132
}
3233

34+
public function __unserialize(array $data): void
35+
{
36+
if (version_compare('7.4.0', Kernel::VERSION, '<')) {
37+
return;
38+
}
39+
40+
$this->capturedBodyLength = null;
41+
42+
parent::__unserialize($data);
43+
}
44+
45+
/**
46+
* @legacy Support Symfony < 7.4
47+
*/
3348
public function __wakeup(): void
3449
{
50+
if (version_compare('8.0.0', Kernel::VERSION, '>=')) {
51+
return;
52+
}
3553
$this->capturedBodyLength = null;
3654

37-
parent::__wakeup();
55+
parent::__wakeup(); /* @phpstan-ignore staticMethod.notFound */
3856
}
3957

4058
public function reset(): void

0 commit comments

Comments
 (0)