Skip to content

Commit 6d1ea3c

Browse files
Merge branch '2.8' into 3.4
* 2.8: [appveyor] fix Revert "minor #28321 [Routing] Fixed the interface description of the url generator interface (Toflar)" 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 5e1a426 + 6c0f496 commit 6d1ea3c

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
@@ -450,11 +450,17 @@ public function uploadedFileErrorProvider()
450450
'{{ suffix }}' => 'bytes',
451451
), '1');
452452

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

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

0 commit comments

Comments
 (0)