bug #33568 [Validator] don't change state in case of exception (xabbuh)

This PR was merged into the 4.4 branch.

Discussion
----------

[Validator] don't change state in case of exception

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Commits
-------

dcd47335a8 don't change state in case of exception
This commit is contained in:
Fabien Potencier 2019-09-13 15:19:20 +01:00
commit 5d94ace5ea

View File

@ -255,12 +255,12 @@ class ValidatorBuilder implements ValidatorBuilderInterface
*/
public function setMappingCache(CacheItemPoolInterface $cache)
{
$this->mappingCache = $cache;
if (null !== $this->metadataFactory) {
throw new ValidatorException('You cannot set a custom mapping cache after setting a custom metadata factory. Configure your metadata factory instead.');
}
$this->mappingCache = $cache;
return $this;
}