Skip to content
Permalink
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
  • Loading branch information...
nicolas-grekas committed Oct 30, 2019
2 parents c424c5a + 27b0baa commit 1aaf58b55a8ed06fcf635a069a8b152f89cd6981
2 link
@@ -66,6 +66,6 @@ foreach (glob("$pathToProject/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as
echo "\"$package\" has been linked to \"$sfPackages[$package]\".".PHP_EOL;
}
foreach (glob("$pathToProject/var/cache/*") as $cacheDir) {
foreach (glob("$pathToProject/var/cache/*", GLOB_NOSORT) as $cacheDir) {
$filesystem->remove($cacheDir);
}
@@ -148,15 +148,15 @@
<argument /> <!-- name -->
<argument /> <!-- user_checker -->
<argument /> <!-- request_matcher -->
<argument /> <!-- security enabled -->
<argument /> <!-- stateless -->
<argument>false</argument> <!-- security enabled -->
<argument>false</argument> <!-- stateless -->
<argument /> <!-- provider -->
<argument /> <!-- context -->
<argument /> <!-- entry_point -->
<argument /> <!-- access_denied_handler -->
<argument /> <!-- access_denied_url -->
<argument type="collection" /> <!-- listeners -->
<argument /> <!-- switch_user -->
<argument>null</argument> <!-- switch_user -->
</service>

<service id="security.logout_url_generator" class="Symfony\Component\Security\Http\Logout\LogoutUrlGenerator">
@@ -99,7 +99,9 @@ public function getIterator()
$prefix = str_replace('\\', '/', $this->prefix);
if (0 !== strpos($this->prefix, 'phar://') && false === strpos($this->pattern, '/**/') && (\defined('GLOB_BRACE') || false === strpos($this->pattern, '{'))) {
foreach (glob($this->prefix.$this->pattern, \defined('GLOB_BRACE') ? GLOB_BRACE : 0) as $path) {
$paths = glob($this->prefix.$this->pattern, GLOB_NOSORT | (\defined('GLOB_BRACE') ? GLOB_BRACE : 0));
sort($paths);
foreach ($paths as $path) {
if ($this->excludedPrefixes) {
$normalizedPath = str_replace('\\', '/', $path);
do {
@@ -595,7 +595,8 @@ public function in($dirs)
foreach ((array) $dirs as $dir) {
if (is_dir($dir)) {
$resolvedDirs[] = $this->normalizeDir($dir);
} elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
} elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR | GLOB_NOSORT)) {
sort($glob);
$resolvedDirs = array_merge($resolvedDirs, array_map([$this, 'normalizeDir'], $glob));
} else {
throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));
@@ -465,7 +465,7 @@ private function buildXml(\DOMNode $parentNode, $data, string $xmlRootNodeName =
return $this->appendNode($parentNode, $data, 'data');
}
throw new NotEncodableValueException(sprintf('An unexpected value could not be serialized: %s', var_export($data, true)));
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))));
}
/**
@@ -173,7 +173,7 @@ public function normalize($data, $format = null, array $context = [])
throw new NotNormalizableValueException(sprintf('Could not normalize object of type %s, no supporting normalizer found.', \get_class($data)));
}
throw new NotNormalizableValueException(sprintf('An unexpected value could not be normalized: %s', var_export($data, true)));
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))));
}
/**
@@ -14,6 +14,7 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Serializer\Encoder\XmlEncoder;
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
use Symfony\Component\Serializer\Normalizer\CustomNormalizer;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Serializer;
@@ -796,6 +797,14 @@ public function testEncodeXmlWithDateTimeObjectField()
$this->assertEquals($this->createXmlWithDateTimeField(), $actualXml);
}
public function testNotEncodableValueExceptionMessageForAResource()
{
$this->expectException(NotEncodableValueException::class);
$this->expectExceptionMessage('An unexpected value could not be serialized: stream resource');
(new XmlEncoder())->encode(tmpfile(), 'xml');
}
public function testEncodeComment()
{
$expected = <<<'XML'
@@ -17,6 +17,7 @@
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorFromClassMetadata;
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
use Symfony\Component\Serializer\Mapping\ClassMetadata;
@@ -468,6 +469,14 @@ public function testExceptionWhenTypeIsNotInTheBodyToDeserialiaze()
$this->serializerWithClassDiscriminator()->deserialize('{"one":1}', DummyMessageInterface::class, 'json');
}
public function testNotNormalizableValueExceptionMessageForAResource()
{
$this->expectException(NotNormalizableValueException::class);
$this->expectExceptionMessage('An unexpected value could not be normalized: stream resource');
(new Serializer())->normalize(tmpfile());
}
private function serializerWithClassDiscriminator()
{
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
@@ -89,7 +89,8 @@ function findTranslationFiles($originalFilePath, $localeToAnalyze)
$originalFileName = basename($originalFilePath);
$translationFileNamePattern = str_replace('.en.', '.*.', $originalFileName);
$translationFiles = glob($translationsDir.'/'.$translationFileNamePattern);
$translationFiles = glob($translationsDir.'/'.$translationFileNamePattern, GLOB_NOSORT);
sort($translationFiles);
foreach ($translationFiles as $filePath) {
$locale = extractLocaleFromFilePath($filePath);

0 comments on commit 1aaf58b

Please sign in to comment.
You can’t perform that action at this time.