[BUGFIX] Fix validation for objects of the same type 64/43564/3
authorStephan Großberndt <stephan@grossberndt.de>
Fri, 25 Sep 2015 10:13:19 +0000 (12:13 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Fri, 25 Sep 2015 11:37:36 +0000 (13:37 +0200)
The patch http://review.typo3.org/40693 introduced a regression by
replacing a count() check on a countable object with a !empty() check,
which lead to failing validations for objects of the same type.

Since getBaseValidatorConjunction() returns either an object or NULL
check for NULL instead and make the countable call explicit.

getBaseValidatorConjunction() doesn't have a second parameter in the
backport, thus remove that parameter.

Resolves: #70017
Related: #67786
Releases: master
Change-Id: I141ecb0b14f6dcebc2908a27009abc0c3f3ccf75
Reviewed-on: http://review.typo3.org/43564
Reviewed-by: Torben Hansen <derhansen@gmail.com>
Tested-by: Torben Hansen <derhansen@gmail.com>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php

index ded58a9..1a9a44b 100644 (file)
@@ -284,8 +284,8 @@ class ValidatorResolver implements \TYPO3\CMS\Core\SingletonInterface {
                                                $collectionValidator = $this->createValidator(\TYPO3\CMS\Extbase\Validation\Validator\CollectionValidator::class, array('elementType' => $parsedType['elementType'], 'validationGroups' => $validationGroups));
                                                $objectValidator->addPropertyValidator($classPropertyName, $collectionValidator);
                                        } elseif (class_exists($propertyTargetClassName) && !TypeHandlingUtility::isCoreType($propertyTargetClassName) && $this->objectManager->isRegistered($propertyTargetClassName) && $this->objectManager->getScope($propertyTargetClassName) === \TYPO3\CMS\Extbase\Object\Container\Container::SCOPE_PROTOTYPE) {
-                                               $validatorForProperty = $this->getBaseValidatorConjunction($propertyTargetClassName, $validationGroups);
-                                               if (!empty($validatorForProperty)) {
+                                               $validatorForProperty = $this->getBaseValidatorConjunction($propertyTargetClassName);
+                                               if ($validatorForProperty !== NULL && $validatorForProperty->count() > 0) {
                                                        $objectValidator->addPropertyValidator($classPropertyName, $validatorForProperty);
                                                }
                                        }