8000 Merge branch '3.4' into 4.3 · symfony/symfony@1aaf58b · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1aaf58b

Browse files
Merge branch '3.4' into 4.3
* 3.4: [Config] Disable default alphabet sorting in glob function due of unstable sort [Serializer] Improve messages for unexpected resources values [SecurityBundle] correct types for default arguments for firewall configs
2 parents c424c5a + 27b0baa commit 1aaf58b

File tree

9 files changed

+31
-9
lines changed

9 files changed

+31
-9
lines changed

link

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ foreach (glob("$pathToProject/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as
6666
echo "\"$package\" has been linked to \"$sfPackages[$package]\".".PHP_EOL;
6767
}
6868

69-
foreach (glob("$pathToProject/var/cache/*") as $cacheDir) {
69+
foreach (glob("$pathToProject/var/cache/*", GLOB_NOSORT) as $cacheDir) {
7070
$filesystem->remove($cacheDir);
7171
}

src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,15 @@
148148
<argument /> <!-- name -->
149149
<argument /> <!-- user_checker -->
150150
<argument /> <!-- request_matcher -->
151-
<argument /> <!-- security enabled -->
152-
<argument /> <!-- stateless -->
151+
<argument>false</argument> <!-- security enabled -->
152+
<argument>false</argument> <!-- stateless -->
153153
<argument /> <!-- provider -->
154154
<argument /> <!-- context -->
155155
<argument /> <!-- entry_point -->
156156
<argument /> <!-- access_denied_handler -->
157157
<argument /> <!-- access_denied_url -->
158158
<argument type="collection" /> <!-- listeners -->
159-
<argument /> <!-- switch_user -->
159+
<argument>null</argument> <!-- switch_user -->
160160
</service>
161161

162162
<service id="security.logout_url_generator" class="Symfony\Component\Security\Http\Logout\LogoutUrlGenerator">

src/Symfony/Component/Config/Resource/GlobResource.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ public function getIterator()
9999
$prefix = str_replace('\\', '/', $this->prefix);
100100

101101
if (0 !== strpos($this->prefix, 'phar://') && false === strpos($this->pattern, '/**/') && (\defined('GLOB_BRACE') || false === strpos($this->pattern, '{'))) {
102-
foreach (glob($this->prefix.$this->pattern, \defined('GLOB_BRACE') ? GLOB_BRACE : 0) as $path) {
102+
$paths = glob($this->prefix.$this->pattern, GLOB_NOSORT | (\defined('GLOB_BRACE') ? GLOB_BRACE : 0));
103+
sort($paths);
104+
foreach ($paths as $path) {
103105
if ($this->excludedPrefixes) {
104106
$normalizedPath = str_replace('\\', '/', $path);
105107
do {

src/Symfony/Component/Finder/Finder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,8 @@ public function in($dirs)
595595
foreach ((array) $dirs as $dir) {
596596
if (is_dir($dir)) {
597597
$resolvedDirs[] = $this->normalizeDir($dir);
598-
} elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
598+
} elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR | GLOB_NOSORT)) {
599+
sort($glob);
599600
$resolvedDirs = array_merge($resolvedDirs, array_map([$this, 'normalizeDir'], $glob));
600601
} else {
601602
throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));

src/Symfony/Component/Serializer/Encoder/XmlEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ private function buildXml(\DOMNode $parentNode, $data, string $xmlRootNodeName =
465465
return $this->appendNode($parentNode, $data, 'data');
466466
}
467467

468-
throw new NotEncodableValueException(sprintf('An unexpected value could not be serialized: %s', var_export($data, true)));
468+
throw new NotEncodableValueException(sprintf('An unexpected value could not be serialized: %s', !\is_resource($data) ? var_export($data, true) : sprintf('%s resource', get_resource_type($data))));
469469
}
470470

471471
/**

src/Symfony/Component/Serializer/Serializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public function normalize($data, $format = null, array $context = [])
173173
throw new NotNormalizableValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', \get_class($data)));
174174
}
175175

176-
throw new NotNormalizableValueException(sprintf('An unexpected value could not be normalized: %s', var_export($data, true)));
176+
throw new NotNormalizableValueException(sprintf('An unexpected value could not be normalized: %s', !\is_resource($data) ? var_export($data, true) : sprintf('%s resource', get_resource_type($data))));
177177
}
178178

179179
/**

src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\MockObject\MockObject;
1515
use PHPUnit\Framework\TestCase;
1616
use Symfony\Component\Serializer\Encoder\XmlEncoder;
17+
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
1718
use Symfony\Component\Serializer\Normalizer\CustomNormalizer;
1819
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
1920
use Symfony\Component\Serializer\Serializer;
@@ -796,6 +797,14 @@ public function testEncodeXmlWithDateTimeObjectField()
796797
$this->assertEquals($this->createXmlWithDateTimeField(), $actualXml);
797798
}
798799

800+
public function testNotEncodableValueExceptionMessageForAResource()
801+
{
802+
$this->expectException(NotEncodableValueException::class);
803+
$this->expectExceptionMessage('An unexpected value could not be serialized: stream resource');
804+
805+
(new XmlEncoder())->encode(tmpfile(), 'xml');
806+
}
807+
799808
public function testEncodeComment()
800809
{
801810
$expected = <<<'XML'

src/Symfony/Component/Serializer/Tests/SerializerTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
1818
use Symfony\Component\Serializer\Encoder\JsonEncoder;
1919
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
20+
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
2021
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
2122
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
2223
use Symfony\Component\Serializer\Mapping\ClassMetadata;
@@ -468,6 +469,14 @@ public function testExceptionWhenTypeIsNotInTheBodyToDeserialiaze()
468469
$this->serializerWithClassDiscriminator()->deserialize('{"one":1}', DummyMessageInterface::class, 'json');
469470
}
470471

472+
public function testNotNormalizableValueExceptionMessageForAResource()
473+
{
474+
$this->expectException(NotNormalizableValueException::class);
475+
$this->expectExceptionMessage('An unexpected value could not be normalized: stream resource');
476+
477+
(new Serializer())->normalize(tmpfile());
478+
}
479+
471480
private function serializerWithClassDiscriminator()
472481
{
473482
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));

src/Symfony/Component/Translation/Resources/bin/translation-status.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ function findTranslationFiles($originalFilePath, $localeToAnalyze)
8989
$originalFileName = basename($originalFilePath);
9090
$translationFileNamePattern = str_replace('.en.', '.*.', $originalFileName);
9191

92-
$translationFiles = glob($translationsDir.'/'.$translationFileNamePattern);
92+
$translationFiles = glob($translationsDir.'/'.$translationFileNamePattern, GLOB_NOSORT);
93+
sort($translationFiles);
9394
foreach ($translationFiles as $filePath) {
9495
$locale = extractLocaleFromFilePath($filePath);
9596

0 commit comments

Comments
 (0)
0