[BUGFIX] EXT:form - let the CountValidator provide its arguments 35/52335/6
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Mon, 3 Apr 2017 11:40:56 +0000 (13:40 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 27 Apr 2017 14:52:20 +0000 (16:52 +0200)
* Provide the validator's arguments to TYPO3\CMS\Extbase\Validation\Error
* Prevent PHP errors if sprintf is tried to be called in case of empty
  argument arrays

Resolves: #80653
Releases: master, 8.7
Change-Id: I0f399501bc1091aa0034bd4de8652564535ce3f0
Reviewed-on: https://review.typo3.org/52335
Reviewed-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Tested-by: Bjoern Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/form/Classes/Mvc/Validation/CountValidator.php
typo3/sysext/form/Classes/Service/TranslationService.php
typo3/sysext/form/Resources/Private/Language/locallang.xlf

index e336cdd..a1ea499 100644 (file)
@@ -63,7 +63,7 @@ class CountValidator extends AbstractValidator
                     'form',
                     [$minimum, $maximum]
                 ),
                     'form',
                     [$minimum, $maximum]
                 ),
-                1475002994
+                1475002994, [$this->options['minimum'], $this->options['maximum']]
             );
         }
     }
             );
         }
     }
index e3ff661..bf42a14 100644 (file)
@@ -158,7 +158,7 @@ class TranslationService implements SingletonInterface
             $value = $this->LOCAL_LANG['default'][$key][0]['target'];
         }
 
             $value = $this->LOCAL_LANG['default'][$key][0]['target'];
         }
 
-        if (is_array($arguments) && $value !== null) {
+        if (is_array($arguments) && !empty($arguments) && $value !== null) {
             $value = vsprintf($value, $arguments);
         } else {
             if (empty($value)) {
             $value = vsprintf($value, $arguments);
         } else {
             if (empty($value)) {
index 34c005b..b852a42 100644 (file)
@@ -71,7 +71,7 @@
                 <source>The given subject is not countable.</source>
             </trans-unit>
             <trans-unit id="validation.error.1475002994" xml:space="preserve">
                 <source>The given subject is not countable.</source>
             </trans-unit>
             <trans-unit id="validation.error.1475002994" xml:space="preserve">
-                <source>Please enter a valid number between %s and %s</source>
+                <source>Please select %s to %s elements.</source>
             </trans-unit>
             <trans-unit id="validation.error.1471708997" xml:space="preserve">
                 <source>The given value was not an instance of \TYPO3\CMS\Extbase\Domain\Model\FileReference or \TYPO3\CMS\Core\Resource\File.</source>
             </trans-unit>
             <trans-unit id="validation.error.1471708997" xml:space="preserve">
                 <source>The given value was not an instance of \TYPO3\CMS\Extbase\Domain\Model\FileReference or \TYPO3\CMS\Core\Resource\File.</source>