Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c639531

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: [HttpFoundation] Drop int return type from parseFilesize() Added $translator->addLoader() bug #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 2c8368f + 35c19c8 commit c639531

File tree

17 files changed

+79
-42
lines changed

17 files changed

+79
-42
lines changed

.appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ install:
2626
- echo memory_limit=-1 >> php.ini-min
2727
- echo serialize_precision=-1 >> php.ini-min
2828
- echo max_execution_time=1200 >> php.ini-min
29+
- echo post_max_size=4G >> php.ini-min
30+
- echo upload_max_filesize=4G >> php.ini-min
2931
- echo date.timezone="America/Los_Angeles" >> php.ini-min
3032
- echo extension_dir=ext >> php.ini-min
3133
- echo extension=php_xsl.dll >> php.ini-min

.php_cs.dist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ return PhpCsFixer\Config::create()
1111
'@Symfony' => true,
1212
'@Symfony:risky' => true,
1313
'protected_to_private' => false,
14-
'native_constant_invocation' => true,
15-
'list_syntax' => ['syntax' => 'short'],
1614
])
1715
->setRiskyAllowed(true)
1816
->setFinder(

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ public function loadUserByUsername(string $username)
6262
}
6363

6464
if (null === $user) {
65-
throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
65+
$e = new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
66+
$e->setUsername($username);
67+
68+
throw $e;
6669
}
6770

6871
return $user;
@@ -92,7 +95,10 @@ public function refreshUser(UserInterface $user)
9295

9396
$refreshedUser = $repository->find($id);
9497
if (null === $refreshedUser) {
95-
throw new UsernameNotFoundException('User with id '.json_encode($id).' not found.');
98+
$e = new UsernameNotFoundException('User with id '.json_encode($id).' not found.');
99+
$e->setUsername(json_encode($id));
100+
101+
throw $e;
96102
}
97103
}
98104

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,19 @@
9595

9696
if (\PHP_VERSION_ID >= 80000) {
9797
// PHP 8 requires PHPUnit 9.3+
98-
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.4');
98+
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.4') ?: '9.4';
9999
} elseif (\PHP_VERSION_ID >= 70200) {
100100
// PHPUnit 8 requires PHP 7.2+
101-
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.3');
101+
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.3') ?: '8.3';
102102
} elseif (\PHP_VERSION_ID >= 70100) {
103103
// PHPUnit 7 requires PHP 7.1+
104-
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.5');
104+
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.5') ?: '7.5';
105105
} elseif (\PHP_VERSION_ID >= 70000) {
106106
// PHPUnit 6 requires PHP 7.0+
107-
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5');
107+
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5') ?: '6.5';
108108
} elseif (\PHP_VERSION_ID >= 50600) {
109109
// PHPUnit 4 does not support PHP 7
110-
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7');
110+
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7') ?: '5.7';
111111
} else {
112112
// PHPUnit 5.1 requires PHP 5.6+
113113
$PHPUNIT_VERSION = '4.8';

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/SecuredPageBundle/Security/Core/User/ArrayUserProvider.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ public function loadUserByUsername($username)
3434
$user = $this->getUser($username);
3535

3636
if (null === $user) {
37-
throw new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
37+
$e = new UsernameNotFoundException(sprintf('User "%s" not found.', $username));
38+
$e->setUsername($username);
39+
40+
throw $e;
3841
}
3942

4043
return $user;

src/Symfony/Component/Form/Extension/Core/Type/FileType.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ private function getFileUploadError(int $errorCode)
171171
* Returns the maximum size of an uploaded file as configured in php.ini.
172172
*
173173
* This method should be kept in sync with Symfony\Component\HttpFoundation\File\UploadedFile::getMaxFilesize().
174+
*
175+
* @return int|float The maximum size of an uploaded file in bytes (returns float if size > PHP_INT_MAX)
174176
*/
175-
private static function getMaxFilesize(): int
177+
private static function getMaxFilesize()
176178
{
177179
$iniMax = strtolower(ini_get('upload_max_filesize'));
178180

@@ -207,8 +209,10 @@ private static function getMaxFilesize(): int
207209
* (i.e. try "MB", then "kB", then "bytes").
208210
*
209211
* This method should be kept in sync with Symfony\Component\Validator\Constraints\FileValidator::factorizeSizes().
212+
*
213+
* @param int|float $limit
210214
*/
211-
private function factorizeSizes(int $size, int $limit)
215+
private function factorizeSizes(int $size, $limit)
212216
{
213217
$coef = self::MIB_BYTES;
214218
$coefFactor = self::KIB_BYTES;

src/Symfony/Component/HttpClient/CurlHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function request(string $method, string $url, array $options = []): Respo
170170
$curlopts[\CURLOPT_DNS_USE_GLOBAL_CACHE] = false;
171171
}
172172

173-
if (\defined('CURLOPT_HEADEROPT')) {
173+
if (\defined('CURLOPT_HEADEROPT') && \defined('CURLHEADER_SEPARATE')) {
174174
$curlopts[\CURLOPT_HEADEROPT] = \CURLHEADER_SEPARATE;
175175
}
176176

src/Symfony/Component/HttpFoundation/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;

src/Symfony/Component/HttpFoundation/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

src/Symfony/Component/HttpFoundation/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
}

0 commit comments

Comments
 (0)