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

Skip to content

Commit 9ecb0cd

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: [HttpFoundation] Drop int return type from parseFilesize() Added $translator->addLoader() bug symfony/symfony#39878 [doctrine-bridge] Add username to UserNameNotFoundException fix spelling Add check for constant in Curl client Revert #38614, add assert to avoid regression Fix problem when SYMFONY_PHPUNIT_VERSION is empty string value Update PHP CS Fixer config to v2.18
2 parents 0edfc5d + 7f49c84 commit 9ecb0cd

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< 8000 /code>
{
234236
if ('' === $size) {
235237
return 0;

Request.php

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

18401840
$basename = basename($baseUrl);
1841-
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri).'/', '/'.$basename.'/')) {
1842-
// strip autoindex filename, for virtualhost based on URL path
1843-
$baseUrl = \dirname($baseUrl).'/';
1844-
1845-
$basename = basename($baseUrl);
1846-
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri).'/', '/'.$basename.'/')) {
1847-
// no match whatsoever; set it blank
1848-
return '';
1849-
}
1841+
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) {
1842+
// no match whatsoever; set it blank
1843+
return '';
18501844
}
18511845

18521846
// 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
@@ -1764,8 +1764,8 @@ public function getBaseUrlData()
17641764
'SCRIPT_NAME' => '/foo/app.php',
17651765
'PHP_SELF' => '/foo/app.php',
17661766
],
1767-
'/sub/foo',
1768-
'/bar',
1767+
'',
1768+
'/sub/foo/bar',
17691769
],
17701770
[
17711771
'/sub/foo/app.php/bar',
@@ -1784,8 +1784,18 @@ public function getBaseUrlData()
17841784
'SCRIPT_NAME' => '/foo/app2.phpx',
17851785
'PHP_SELF' => '/foo/app2.phpx',
17861786
],
1787-
'/sub/foo',
1788-
'/bar/baz',
1787+
'',
1788+
'/sub/foo/bar/baz',
1789+
],
1790+
[
1791+
'/foo/api/bar',
1792+
[
1793+
'SCRIPT_FILENAME' => '/var/www/api/index.php',
1794+
'SCRIPT_NAME' => '/api/index.php',
1795+
'PHP_SELF' => '/api/index.php',
1796+
],
1797+
'',
1798+
'/foo/api/bar',
17891799
],
17901800
];
17911801
}

0 commit comments

Comments
 (0)
0