Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee

# Version 2

# 2.3.1 - 2026-04-25

- Fix compatibility issue with Symfony 8.

# 2.3.0 - 2025-01-05

- Compatibility with Symfony 8.
Expand Down
51 changes: 43 additions & 8 deletions src/Collector/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpKernel\Kernel;

/**
* The Collector holds profiled Stacks pushed by the StackPlugin. It also has a list of the configured clients.
Expand All @@ -19,7 +20,7 @@
*
* @internal
*/
final class Collector extends DataCollector
class BaseCollector extends DataCollector
{
private ?Stack $activeStack = null;
private ?int $capturedBodyLength = null;
Expand All @@ -30,13 +31,6 @@ public function __construct(?int $capturedBodyLength = null)
$this->reset();
}

public function __wakeup(): void
{
$this->capturedBodyLength = null;

parent::__wakeup();
}

public function reset(): void
{
$this->data['stacks'] = [];
Expand Down Expand Up @@ -158,4 +152,45 @@ public function collect(Request $request, Response $response, $exception = null)
{
// We do not need to collect any data from the Symfony Request and Response
}

protected function resetBodyLength(): void
{
$this->capturedBodyLength = null;
}
}

if (version_compare('7.4.0', Kernel::VERSION, '>')) {
/**
* @legacy Support Symfony < 7.4
*
* When we drop Support for Symfony < 7.4, remove this hackery.
* - Rename BaseCollector back to Collector
* - Make it final again
* - move __unserialize into BaseCollector and inline resetBodyLength
* - remove the if statement completely
*
* @internal
*/
final class Collector extends BaseCollector
{
public function __wakeup(): void
{
$this->resetBodyLength();

parent::__wakeup(); /* @phpstan-ignore staticMethod.notFound */
}
}
} else {
/**
* @internal
*/
final class Collector extends BaseCollector
{
public function __unserialize(array $data): void
{
$this->resetBodyLength();

parent::__unserialize($data);
}
}
}
Loading