Skip to content

Commit

Permalink
bug #49301 [HttpClient] Fix data collector (fancyweb)
Browse files Browse the repository at this point in the history
This PR was merged into the 5.4 branch.

Discussion
----------

[HttpClient] Fix data collector

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | -
| Tickets       | symfony/symfony#49219
| License       | MIT
| Doc PR        | -

It fixes HTTP requests not showing anymore in the profiler panel because `lateCollect()` overrides `request_count` to 0.

It also fixes the wrong error count.

Commits
-------

8ec869e51e [HttpClient] Fix data collector
  • Loading branch information
nicolas-grekas committed Feb 10, 2023
2 parents 8f377d7 + 18d9063 commit ecda6e7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions DataCollector/HttpClientDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public function collect(Request $request, Response $response, \Throwable $except

public function lateCollect()
{
$this->data['request_count'] = 0;
$this->data['error_count'] = 0;
$this->data['request_count'] = $this->data['request_count'] ?? 0;
$this->data['error_count'] = $this->data['error_count'] ?? 0;
$this->data += ['clients' => []];

foreach ($this->clients as $name => $client) {
Expand All @@ -59,7 +59,8 @@ public function lateCollect()

$this->data['clients'][$name]['traces'] = array_merge($this->data['clients'][$name]['traces'], $traces);
$this->data['request_count'] += \count($traces);
$this->data['error_count'] += $this->data['clients'][$name]['error_count'] += $errorCount;
$this->data['error_count'] += $errorCount;
$this->data['clients'][$name]['error_count'] += $errorCount;

$client->reset();
}
Expand Down

0 comments on commit ecda6e7

Please sign in to comment.