Project

General

Profile

Actions

Bug #88022

closed

Arguments not passed or replaced in FileSize validator error message

Added by Jarvis H over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2019-03-27
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:
Remote Sprint

Description

Description:

FileSize validation message shows with placeholders untouched, like so:
You must select a file that is larger than %s in size.

How to reproduce:

- Create a form with a file input field and add the FileSize validator to it.
- Submit form with file which does not pass file size validation.

Potential cause:

Validation rules for file uploads are handled differently than with other fields as they are called in typo3/sysext/form/Classes/Mvc/Property/TypeConverter/UploadedFileReferenceConverter.php in the method importUploadedResource to prevent file uploads which do not pass validation.

If a validation fails, the method throws a TypeConverterException which is caught and returned as a new error in this part of importUploadedResource->convertFrom:

try {
    $resource = $this->importUploadedResource($source, $configuration);
} catch (\Exception $e) {
    return $this->objectManager->get(Error::class, $e->getMessage(), $e->getCode());
}

First thing I noticed is that the error instance is of the class \TYPO3\CMS\Extbase\Error\Error and not \TYPO3\CMS\Extbase\Validation\Error like the errors for all other fields. I do not know if this poses a problem.

Second, the error is instantiated using only the error message and code, which means all values which should be passed to the "arguments" property of the error instance are lost, hence the untouched "%s" parts of the error string.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #87042: Single errors from FileSizeValidator could not be translatedClosed2018-11-29

Actions
Actions

Also available in: Atom PDF