Skip to content

[HttpKernel] implement reset() in DumpDataCollector #24505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ public function collect(Request $request, Response $response, \Exception $except
}
}

public function reset()
{
$this->stopwatch->reset();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the data collector dealing with Stopwatch is not this one. So it should not be responsible for resetting (the DumpDataCollector uses the stopwatch to profile itself, it does not read from it).

This should be done in the TimeDataCollector instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inside dump() we deal with the Stopwatch in DumpDataCollector too: https://github.com/xabbuh/symfony/blob/dd53319950793f6bbed96e4a8ae764c48f64ebfc/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php#L68

But you are right about the TimeDataCollector. I have updated it too.

$this->data = array();
$this->dataCount = 0;
$this->isCollected = false;
$this->clonesCount = 0;
$this->clonesIndex = 0;
}

public function serialize()
{
if ($this->clonesCount !== $this->clonesIndex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Stopwatch\Stopwatch;

/**
* TimeDataCollector.
Expand All @@ -25,7 +26,7 @@ class TimeDataCollector extends DataCollector implements LateDataCollectorInterf
protected $kernel;
protected $stopwatch;

public function __construct(KernelInterface $kernel = null, $stopwatch = null)
public function __construct(KernelInterface $kernel = null, Stopwatch $stopwatch = null)
{
$this->kernel = $kernel;
$this->stopwatch = $stopwatch;
Expand Down Expand Up @@ -55,6 +56,10 @@ public function collect(Request $request, Response $response, \Exception $except
public function reset()
{
$this->data = array();

if (null !== $this->stopwatch) {
$this->stopwatch->reset();
}
}

/**
Expand Down