[BUGFIX] EXT:form - let the CountValidator provide its arguments 41/52641/3
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Mon, 3 Apr 2017 11:40:56 +0000 (13:40 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 28 Apr 2017 08:00:52 +0000 (10:00 +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/52641
Tested-by: TYPO3com <no-reply@typo3.com>
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]
                 ),
-                1475002994
+                1475002994, [$this->options['minimum'], $this->options['maximum']]
             );
         }
     }
index d1e5e71..dc45246 100644 (file)
@@ -158,7 +158,7 @@ class TranslationService implements SingletonInterface
             $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)) {
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>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>