Skip to content

Commit 83a5dcf

Browse files
Merge branch '3.4' into 4.1
* 3.4: [appveyor] fix Revert "minor #28321 [Routing] Fixed the interface description of the url generator interface (Toflar)" Fixed caching of templates in default path on cache warmup remove cache warmers when Twig cache is disabled [HttpKernel][FrameworkBundle] Fix escaping of serialized payloads passed to test clients chore: rename Appveyor filename Fixed the interface description of the url generator interface Format file size in validation message according to binaryFormat option
2 parents 07c00fc + 6d1ea3c commit 83a5dcf

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Constraints/FileValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function validate($value, Constraint $constraint)
5757
$binaryFormat = $constraint->binaryFormat;
5858
} else {
5959
$limitInBytes = $iniLimitSize;
60-
$binaryFormat = true;
60+
$binaryFormat = null === $constraint->binaryFormat ? true : $constraint->binaryFormat;
6161
}
6262

6363
list($sizeAsString, $limitAsString, $suffix) = $this->factorizeSizes(0, $limitInBytes, $binaryFormat);

Tests/Constraints/FileValidatorTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,17 @@ public function uploadedFileErrorProvider()
451451
'{{ suffix }}' => 'bytes',
452452
), '1');
453453

454+
// access FileValidator::factorizeSizes() private method to format max file size
455+
$reflection = new \ReflectionClass(\get_class(new FileValidator()));
456+
$method = $reflection->getMethod('factorizeSizes');
457+
$method->setAccessible(true);
458+
list($sizeAsString, $limit, $suffix) = $method->invokeArgs(new FileValidator(), array(0, UploadedFile::getMaxFilesize(), false));
459+
454460
// it correctly parses the maxSize option and not only uses simple string comparison
455461
// 1000M should be bigger than the ini value
456462
$tests[] = array(UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', array(
457-
'{{ limit }}' => UploadedFile::getMaxFilesize() / 1048576,
458-
'{{ suffix }}' => 'MiB',
463+
'{{ limit }}' => $limit,
464+
'{{ suffix }}' => $suffix,
459465
), '1000M');
460466

461467
// it correctly parses the maxSize option and not only uses simple string comparison

0 commit comments

Comments
 (0)