8000 Merge branch '5.1' into 5.2 · symfony/http-foundation@6b58477 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b58477

Browse files
committed
Merge branch '5.1' into 5.2
* 5.1: [HttpFoundation] Drop int return type from parseFilesize() Added $translator->addLoader() bug symfony/symfony#39878 [doctrine-bridge] Add username to UserNameNotFoundException [Uid] Clarify the format returned by getTime() fix spelling Add check for constant in Curl client Revert #38614, add assert to avoid regression Fix container injection with TypedReference Fix problem when SYMFONY_PHPUNIT_VERSION is empty string value Update PHP CS Fixer config to v2.18
2 parents 75d2a9e + 9ecb0cd commit 6b58477

File tree

4 files changed

+29
-19
lines changed

4 files changed

+29
-19
lines changed

File/UploadedFile.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function move(string $directory, string $name = null)
216216
/**
217217
* Returns the maximum size of an uploaded file as configured in php.ini.
218218
*
219-
* @return int The maximum size of an uploaded file in bytes
219+
* @return int|float The maximum size of an uploaded file in bytes (returns float if size > PHP_INT_MAX)
220220
*/
221221
public static function getMaxFilesize()
222222
{
@@ -228,8 +228,10 @@ public static function getMaxFilesize()
228228

229229
/**
230230
* Returns the given size from an ini value in bytes.
231+
*
232+
* @return int|float Returns float if size > PHP_INT_MAX
231233
*/
232-
private static function parseFilesize($size): int
234+
private static function parseFilesize($size)
233235
{
234236
if ('' === $size) {
235237
return 0;

Request.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,15 +1895,9 @@ protected function prepareBaseUrl()
18951895
}
18961896

18971897
$basename = basename($baseUrl);
1898-
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri).'/', '/'.$basename.'/')) {
1899-
// strip autoindex filename, for virtualhost based on URL path
1900-
$baseUrl = \dirname($baseUrl).'/';
1901-
1902-
$basename = basename($baseUrl);
1903-
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri).'/', '/'.$basename.'/')) {
1904-
// no match whatsoever; set it blank
1905-
return '';
1906-
}
1898+
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) {
1899+
// no match whatsoever; set it blank
1900+
return '';
19071901
}
19081902

19091903
// If using mod_rewrite or ISAPI_Rewrite strip the script filename

Tests/File/UploadedFileTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\File\Exception\CannotWriteFileException;
1616
use Symfony\Component\HttpFoundation\File\Exception\ExtensionFileException;
1717
use Symfony\Component\HttpFoundation\File\Exception\FileException;
18+
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
1819
use Symfony\Component\HttpFoundation\File\Exception\FormSizeFileException;
1920
use Symfony\Component\HttpFoundation\File\Exception\IniSizeFileException;
2021
use Symfony\Component\HttpFoundation\File\Exception\NoFileException;
@@ -33,7 +34,7 @@ protected function setUp(): void
3334

3435
public function testConstructWhenFileNotExists()
3536
{
36-
$this->expectException(\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException::class);
37+
$this->expectException(FileNotFoundException::class);
3738

3839
new UploadedFile(
3940
__DIR__.'/Fixtures/not_here',
@@ -324,13 +325,16 @@ public function testGetMaxFilesize()
324325
{
325326
$size = UploadedFile::getMaxFilesize();
326327

327-
$this->assertIsInt($size);
328+
if ($size > \PHP_INT_MAX) {
329+
$this->assertIsFloat($size);
330+
} else {
331+
$this->assertIsInt($size);
332+
}
333+
328334
$this->assertGreaterThan(0, $size);
329335

330336
if (0 === (int) ini_get('post_max_size') && 0 === (int) ini_get('upload_max_filesize')) {
331337
$this->assertSame(\PHP_INT_MAX, $size);
332-
} else {
333-
$this->assertLessThan(\PHP_INT_MAX, $size);
334338
}
335339
}
336340
}

Tests/RequestTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,8 +1793,8 @@ public function getBaseUrlData()
17931793
'SCRIPT_NAME' => '/foo/app.php',
17941794
'PHP_SELF' => '/foo/app.php',
17951795
],
1796-
'/sub/foo',
1797-
'/bar',
1796+
'',
1797+
'/sub/foo/bar',
17981798
],
17991799
[
18001800
'/sub/foo/app.php/bar',
@@ -1813,8 +1813,18 @@ public function getBaseUrlData()
18131813
'SCRIPT_NAME' => '/foo/app2.phpx',
18141814
'PHP_SELF' => '/foo/app2.phpx',
18151815
],
1816-
'/sub/foo',
1817-
'/bar/baz',
1816+
'',
1817+
'/sub/foo/bar/baz',
1818+
],
1819+
[
1820+
'/foo/api/bar',
1821+
[
1822+
'SCRIPT_FILENAME' => '/var/www/api/index.php',
1823+
'SCRIPT_NAME' => '/api/index.php',
1824+
'PHP_SELF' => '/api/index.php',
1825+
],
1826+
'',
1827+
'/foo/api/bar',
18181828
],
18191829
];
18201830
}

0 commit comments

Comments
 (0)
0