8000 bug #24770 [Validator] Fix TraceableValidator is reset on data collec… · symfony/symfony@782dc94 · GitHub
[go: up one dir, main page]

Skip to content

Commit 782dc94

Browse files
committed
bug #24770 [Validator] Fix TraceableValidator is reset on data collector instantiation (ogizanagi)
This PR was merged into the 3.4 branch. Discussion ---------- [Validator] Fix TraceableValidator is reset on data collector instantiation | Q | A | ------------- | --- | Branch? | 3.4 <!-- see comment below --> | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | N/A <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A Calling reset from the constructor is wrong in this case as it'll reset the `TraceableValidator`, which means you'll never get collected data on the first request as the collector is instantiated after (on kernel response). Another option would be to tag the `debug.validator` service with `kernel.reset` and remove the reset call from the collector. Commits ------- f5855fb [Validator] Fix TraceableValidator is reset on data collector instantiation
2 parents 5c46e39 + f5855fb commit 782dc94

File tree

3 files changed

+1
-6
lines changed

3 files changed

+1
-6
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/validator_debug.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
<service id="debug.validator" decorates="validator" decoration-priority="255" class="Symfony\Component\Validator\Validator\TraceableValidator">
1111
<argument type="service" id="debug.validator.inner" />
12+
<tag name="kernel.reset" method="reset" />
1213
</service>
1314

1415
<!-- DataCollector -->

src/Symfony/Component/Validator/DataCollector/ValidatorDataCollector.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public function collect(Request $request, Response $response, \Exception $except
4545

4646
public function reset()
4747
{
48-
$this->validator->reset();
4948
$this->data = array(
5049
'calls' => $this->cloneVar(array()),
5150
'violations_count' => 0,

src/Symfony/Component/Validator/Tests/DataCollector/ValidatorDataCollectorTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ public function testReset()
7070

7171
$this->assertCount(0, $collector->getCalls());
7272
$this->assertSame(0, $collector->getViolationsCount());
73-
74-
$collector->lateCollect();
75-
76-
$this->assertCount(0, $collector->getCalls());
77-
$this->assertSame(0, $collector->getViolationsCount());
7873
}
7974

8075
protected function createMock($classname)

0 commit comments

Comments
 (0)
0