From 0d14aac8801661b75b7a4e070f9785eddadf6f70 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Fri, 20 May 2016 15:47:36 +0200 Subject: [PATCH 01/11] Removed UTC specification with timestamp --- .../DataTransformer/DateTimeToLocalizedStringTransformer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php index b38680a1bb..5418f7feae 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php @@ -126,7 +126,7 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer try { // read timestamp into DateTime object - the formatter delivers in UTC - $dateTime = new \DateTime(sprintf('@%s UTC', $timestamp)); + $dateTime = new \DateTime(sprintf('@%s', $timestamp)); } catch (\Exception $e) { throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); } From 142b1a4b468505c4a6bdd44625c959fc2dfebf27 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 29 May 2016 12:39:28 +0200 Subject: [PATCH 02/11] force enabling the external XML entity loaders --- .../DependencyInjection/Loader/XmlFileLoader.php | 2 ++ .../Tests/Loader/XmlFileLoaderTest.php | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index f324aa969c..076f4fa659 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -333,7 +333,9 @@ $imports EOF ; + $disableEntities = libxml_disable_entity_loader(false); $valid = @$dom->schemaValidateSource($source); + libxml_disable_entity_loader($disableEntities); foreach ($tmpfiles as $tmpfile) { @unlink($tmpfile); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index a8f8f35133..d2e2a684a8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -83,6 +83,19 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\SimpleXMLElement', $xml, '->parseFile() returns an SimpleXMLElement object'); } + public function testLoaderTurnsOnEntityLoaderIfNecessary() + { + $oldValue = libxml_disable_entity_loader(true); + + $containerBuilder = new ContainerBuilder(); + $loader = new XmlFileLoader($containerBuilder, new FileLocator(self::$fixturesPath.'/xml')); + $loader->load('services2.xml'); + + libxml_disable_entity_loader($oldValue); + + $this->assertTrue(count($containerBuilder->getParameterBag()->all()) > 0, 'Parameters can be read from the config file.'); + } + public function testLoadParameters() { $container = new ContainerBuilder(); From 7d78196d0c25188eb3c16c9f0fc7cfa2706612c7 Mon Sep 17 00:00:00 2001 From: Anton Bakai Date: Tue, 24 May 2016 23:58:05 +0300 Subject: [PATCH 03/11] Fix for #18843 --- src/Symfony/Component/Yaml/Dumper.php | 2 +- src/Symfony/Component/Yaml/Inline.php | 30 +++++++++++++++---- .../Component/Yaml/Tests/InlineTest.php | 20 +++++++++++++ 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/Symfony/Component/Yaml/Dumper.php b/src/Symfony/Component/Yaml/Dumper.php index 21351a5c34..9bd9389c07 100644 --- a/src/Symfony/Component/Yaml/Dumper.php +++ b/src/Symfony/Component/Yaml/Dumper.php @@ -58,7 +58,7 @@ class Dumper if ($inline <= 0 || !is_array($input) || empty($input)) { $output .= $prefix.Inline::dump($input, $exceptionOnInvalidType, $objectSupport); } else { - $isAHash = array_keys($input) !== range(0, count($input) - 1); + $isAHash = Inline::isHash($input); foreach ($input as $key => $value) { $willBeInlined = $inline - 1 <= 0 || !is_array($value) || empty($value); diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 5f15e3c5b4..0ce1ced7d7 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -145,6 +145,28 @@ class Inline } } + /** + * Check if given array is hash or just normal indexed array. + * + * @internal + * + * @param array $value The PHP array to check + * + * @return bool true if value is hash array, false otherwise + */ + public static function isHash(array $value) + { + $expectedKey = 0; + + foreach ($value as $key => $val) { + if ($key !== $expectedKey++) { + return true; + } + } + + return false; + } + /** * Dumps a PHP array to a YAML string. * @@ -157,11 +179,7 @@ class Inline private static function dumpArray($value, $exceptionOnInvalidType, $objectSupport) { // array - $keys = array_keys($value); - $keysCount = count($keys); - if ((1 === $keysCount && '0' == $keys[0]) - || ($keysCount > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) === $keysCount * ($keysCount - 1) / 2) - ) { + if ($value && !self::isHash($value)) { $output = array(); foreach ($value as $val) { $output[] = self::dump($val, $exceptionOnInvalidType, $objectSupport); @@ -170,7 +188,7 @@ class Inline return sprintf('[%s]', implode(', ', $output)); } - // mapping + // hash $output = array(); foreach ($value as $key => $val) { $output[] = sprintf('%s: %s', self::dump($key, $exceptionOnInvalidType, $objectSupport), self::dump($val, $exceptionOnInvalidType, $objectSupport)); diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index 255928d16d..b1263d8d29 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -169,6 +169,24 @@ class InlineTest extends \PHPUnit_Framework_TestCase Inline::parse('{ foo: * #foo }'); } + /** + * @dataProvider getDataForIsHash + */ + public function testIsHash($array, $expected) + { + $this->assertSame($expected, Inline::isHash($array)); + } + + public function getDataForIsHash() + { + return array( + array(array(), false), + array(array(1, 2, 3), false), + array(array(2 => 1, 1 => 2, 0 => 3), true), + array(array('foo' => 1, 'bar' => 2), true), + ); + } + protected function getTestsForParse() { return array( @@ -296,6 +314,8 @@ class InlineTest extends \PHPUnit_Framework_TestCase '[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]' => array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo'))), '[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']' => array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container'), + + '{ foo: { bar: { 1: 2, baz: 3 } } }' => array('foo' => array('bar' => array(1 => 2, 'baz' => 3))), ); } } From b73400d70777ea4179230ada751bfd461b467310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Tue, 24 May 2016 11:36:46 +0100 Subject: [PATCH 04/11] [Serializer] Add missing @throws annotations --- src/Symfony/Component/Serializer/Encoder/ChainDecoder.php | 2 +- .../Component/Serializer/Encoder/DecoderInterface.php | 4 ++++ .../Component/Serializer/Encoder/EncoderInterface.php | 4 ++++ src/Symfony/Component/Serializer/Encoder/XmlEncoder.php | 2 ++ .../Serializer/Normalizer/DenormalizableInterface.php | 6 ++++++ .../Serializer/Normalizer/DenormalizerInterface.php | 4 ++++ .../Serializer/Normalizer/NormalizableInterface.php | 4 ++++ .../Component/Serializer/Normalizer/NormalizerInterface.php | 4 ++++ src/Symfony/Component/Serializer/Serializer.php | 4 ++++ src/Symfony/Component/Serializer/SerializerInterface.php | 6 ++++++ 10 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Serializer/Encoder/ChainDecoder.php b/src/Symfony/Component/Serializer/Encoder/ChainDecoder.php index f8f17b4f72..352ba584a7 100644 --- a/src/Symfony/Component/Serializer/Encoder/ChainDecoder.php +++ b/src/Symfony/Component/Serializer/Encoder/ChainDecoder.php @@ -59,7 +59,7 @@ class ChainDecoder implements DecoderInterface * * @return DecoderInterface * - * @throws RuntimeException if no decoder is found + * @throws RuntimeException If no decoder is found. */ private function getDecoder($format) { diff --git a/src/Symfony/Component/Serializer/Encoder/DecoderInterface.php b/src/Symfony/Component/Serializer/Encoder/DecoderInterface.php index be788ee7c5..3b3e478e7b 100644 --- a/src/Symfony/Component/Serializer/Encoder/DecoderInterface.php +++ b/src/Symfony/Component/Serializer/Encoder/DecoderInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Serializer\Encoder; +use Symfony\Component\Serializer\Exception\Exception; + /** * Defines the interface of decoders. * @@ -30,6 +32,8 @@ interface DecoderInterface * are encouraged to document which formats they support in a non-inherited * phpdoc comment. * + * @throws Exception + * * @return mixed */ public function decode($data, $format, array $context = array()); diff --git a/src/Symfony/Component/Serializer/Encoder/EncoderInterface.php b/src/Symfony/Component/Serializer/Encoder/EncoderInterface.php index 1ac6a17180..662a087ad4 100644 --- a/src/Symfony/Component/Serializer/Encoder/EncoderInterface.php +++ b/src/Symfony/Component/Serializer/Encoder/EncoderInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Serializer\Encoder; +use Symfony\Component\Serializer\Exception\Exception; + /** * Defines the interface of encoders. * @@ -25,6 +27,8 @@ interface EncoderInterface * @param string $format Format name * @param array $context options that normalizers/encoders have access to. * + * @throws Exception + * * @return string|bool|int|float|null */ public function encode($data, $format, array $context = array()); diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php index 6a2b5cf452..247cb9382b 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -399,6 +399,8 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec * @param \DOMNode $node * @param mixed $val * + * @throws UnexpectedValueException + * * @return bool */ private function selectNodeType(\DOMNode $node, $val) diff --git a/src/Symfony/Component/Serializer/Normalizer/DenormalizableInterface.php b/src/Symfony/Component/Serializer/Normalizer/DenormalizableInterface.php index 55c030c7c4..b3bbf50a6d 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DenormalizableInterface.php +++ b/src/Symfony/Component/Serializer/Normalizer/DenormalizableInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Serializer\Normalizer; +use Symfony\Component\Serializer\Exception\Exception; + /** * Defines the most basic interface a class must implement to be denormalizable. * @@ -33,6 +35,10 @@ interface DenormalizableInterface * @param string|null $format The format is optionally given to be able to denormalize differently * based on different input formats. * @param array $context options for denormalizing + * + * @throws Exception + * + * @return object */ public function denormalize(DenormalizerInterface $denormalizer, $data, $format = null, array $context = array()); } diff --git a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php index 8b6c233395..40c5890bd3 100644 --- a/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php +++ b/src/Symfony/Component/Serializer/Normalizer/DenormalizerInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Serializer\Normalizer; +use Symfony\Component\Serializer\Exception\Exception; + /** * Defines the interface of denormalizers. * @@ -26,6 +28,8 @@ interface DenormalizerInterface * @param string $format format the given data was extracted from * @param array $context options available to the denormalizer * + * @throws Exception + * * @return object */ public function denormalize($data, $class, $format = null, array $context = array()); diff --git a/src/Symfony/Component/Serializer/Normalizer/NormalizableInterface.php b/src/Symfony/Component/Serializer/Normalizer/NormalizableInterface.php index 79cba123ff..9f323b9d0c 100644 --- a/src/Symfony/Component/Serializer/Normalizer/NormalizableInterface.php +++ b/src/Symfony/Component/Serializer/Normalizer/NormalizableInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Serializer\Normalizer; +use Symfony\Component\Serializer\Exception\Exception; + /** * Defines the most basic interface a class must implement to be normalizable. * @@ -33,6 +35,8 @@ interface NormalizableInterface * based on different output formats. * @param array $context Options for normalizing this object * + * @throws Exception + * * @return array|string|bool|int|float|null */ public function normalize(NormalizerInterface $normalizer, $format = null, array $context = array()); diff --git a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php index 2a51d631b1..0ce5b3aef2 100644 --- a/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php +++ b/src/Symfony/Component/Serializer/Normalizer/NormalizerInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Serializer\Normalizer; +use Symfony\Component\Serializer\Exception\Exception; + /** * Defines the interface of normalizers. * @@ -25,6 +27,8 @@ interface NormalizerInterface * @param string $format format the normalization result will be encoded as * @param array $context Context options for the normalizer * + * @throws Exception + * * @return array|string|bool|int|float|null */ public function normalize($object, $format = null, array $context = array()); diff --git a/src/Symfony/Component/Serializer/Serializer.php b/src/Symfony/Component/Serializer/Serializer.php index c3e07e821c..6160b5205c 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -169,6 +169,8 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz /** * {@inheritdoc} + * + * @throws RuntimeException */ private function getNormalizer($data, $format = null) { @@ -183,6 +185,8 @@ class Serializer implements SerializerInterface, NormalizerInterface, Denormaliz /** * {@inheritdoc} + * + * @throws RuntimeException */ private function getDenormalizer($data, $type, $format = null) { diff --git a/src/Symfony/Component/Serializer/SerializerInterface.php b/src/Symfony/Component/Serializer/SerializerInterface.php index c79db91892..ed2e71c2cd 100644 --- a/src/Symfony/Component/Serializer/SerializerInterface.php +++ b/src/Symfony/Component/Serializer/SerializerInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Serializer; +use Symfony\Component\Serializer\Exception\Exception; + /** * Defines the interface of the Serializer. * @@ -25,6 +27,8 @@ interface SerializerInterface * @param string $format format name * @param array $context options normalizers/encoders have access to * + * @throws Exception + * * @return string */ public function serialize($data, $format, array $context = array()); @@ -37,6 +41,8 @@ interface SerializerInterface * @param string $format * @param array $context * + * @throws Exception + * * @return object */ public function deserialize($data, $type, $format, array $context = array()); From 893cf00a52ed1f35f06d41e06b575be776fdc17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Proch=C3=A1zka?= Date: Thu, 12 May 2016 17:11:08 +0200 Subject: [PATCH 05/11] Catch \Throwable --- .../Bundle/FrameworkBundle/Routing/DelegatingLoader.php | 5 ++++- .../WebProfilerBundle/Controller/ProfilerController.php | 5 +++-- src/Symfony/Component/Config/Loader/FileLoader.php | 3 +++ src/Symfony/Component/DependencyInjection/Container.php | 5 +++++ .../Component/DependencyInjection/ContainerBuilder.php | 4 ++++ .../DependencyInjection/ContainerAwareHttpKernel.php | 5 +++++ 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php index b37bee83d4..801149372a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php @@ -77,6 +77,9 @@ class DelegatingLoader extends BaseDelegatingLoader } catch (\Exception $e) { $this->loading = false; throw $e; + } catch (\Throwable $e) { + $this->loading = false; + throw $e; } $this->loading = false; @@ -85,7 +88,7 @@ class DelegatingLoader extends BaseDelegatingLoader if ($controller = $route->getDefault('_controller')) { try { $controller = $this->parser->parse($controller); - } catch (\Exception $e) { + } catch (\InvalidArgumentException $e) { // unable to optimize unknown notation } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index 173616fd9f..a152313df9 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -18,6 +18,7 @@ use Symfony\Component\HttpKernel\Profiler\Profiler; use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager; +use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** @@ -193,8 +194,8 @@ class ProfilerController $url = null; try { $url = $this->generator->generate('_profiler', array('token' => $token)); - } catch (\Exception $e) { - // the profiler is not enabled + } catch (RouteNotFoundException $e) { + // the named route doesn't exist => the profiler is not enabled } return new Response($this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array( diff --git a/src/Symfony/Component/Config/Loader/FileLoader.php b/src/Symfony/Component/Config/Loader/FileLoader.php index 9c1b4d9f1e..f25d477069 100644 --- a/src/Symfony/Component/Config/Loader/FileLoader.php +++ b/src/Symfony/Component/Config/Loader/FileLoader.php @@ -108,6 +108,9 @@ abstract class FileLoader extends Loader } catch (\Exception $e) { unset(self::$loading[$resource]); throw $e; + } catch (\Throwable $e) { + unset(self::$loading[$resource]); + throw $e; } unset(self::$loading[$resource]); diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 9243b66c8e..084c4da6fe 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -320,6 +320,11 @@ class Container implements IntrospectableContainerInterface return; } + throw $e; + } catch (\Throwable $e) { + unset($this->loading[$id]); + unset($this->services[$id]); + throw $e; } diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index ad2f89ae77..7c60f0a7d4 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -461,6 +461,10 @@ class ContainerBuilder extends Container implements TaggedContainerInterface return; } + throw $e; + } catch (\Throwable $e) { + unset($this->loading[$id]); + throw $e; } diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php b/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php index c9b8a211d4..e288720b97 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php @@ -64,6 +64,11 @@ class ContainerAwareHttpKernel extends HttpKernel $this->container->set('request', null, 'request'); $this->container->leaveScope('request'); + throw $e; + } catch (\Throwable $e) { + $this->container->set('request', null, 'request'); + $this->container->leaveScope('request'); + throw $e; } From 6f3673364e9bdd8ae96a7b242310e4931dbe68ad Mon Sep 17 00:00:00 2001 From: Robert Meijers Date: Thu, 26 May 2016 16:08:43 +0200 Subject: [PATCH 06/11] [DependencyInjection] Skip deep reference check for 'service_container' Deep checks on whether a service references another service need to exclude the 'service_container' service as it doesn't exist. Without this dumping the container will fail if a service definition references an inlined service which has a direct or indirect dependency to the service_container. --- .../DependencyInjection/Dumper/PhpDumper.php | 2 +- .../Tests/Dumper/PhpDumperTest.php | 11 ++++ .../Tests/Fixtures/php/services13.php | 54 +++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index d239b7d7d5..d7ab4fc2b8 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -1173,7 +1173,7 @@ EOF; return true; } - if ($deep && !isset($visited[(string) $argument])) { + if ($deep && !isset($visited[(string) $argument]) && 'service_container' !== (string) $argument) { $visited[(string) $argument] = true; $service = $this->container->getDefinition((string) $argument); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index 311026c5e6..219ea63e82 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -226,4 +226,15 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase $dumper = new PhpDumper($container); $dumper->dump(); } + + public function testInlinedDefinitionReferencingServiceContainer() + { + $container = new ContainerBuilder(); + $container->register('foo', 'stdClass')->addMethodCall('add', array(new Reference('service_container')))->setPublic(false); + $container->register('bar', 'stdClass')->addArgument(new Reference('foo')); + $container->compile(); + + $dumper = new PhpDumper($container); + $this->assertStringEqualsFile(self::$fixturesPath.'/php/services13.php', $dumper->dump(), '->dump() dumps inline definitions which reference service_container'); + } } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php new file mode 100644 index 0000000000..0c33b7b3ea --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php @@ -0,0 +1,54 @@ +services = + $this->scopedServices = + $this->scopeStacks = array(); + $this->scopes = array(); + $this->scopeChildren = array(); + $this->methodMap = array( + 'bar' => 'getBarService', + ); + + $this->aliases = array(); + } + + /** + * Gets the 'bar' service. + * + * This service is shared. + * This method always returns the same instance of the service. + * + * @return \stdClass A stdClass instance. + */ + protected function getBarService() + { + $a = new \stdClass(); + $a->add($this); + + return $this->services['bar'] = new \stdClass($a); + } +} From b3cd2679b861a249f31253ed6e67187190fb25cc Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 30 May 2016 10:16:24 +0200 Subject: [PATCH 07/11] Partial revert of previous PR --- .../WebProfilerBundle/Controller/ProfilerController.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index a152313df9..173616fd9f 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -18,7 +18,6 @@ use Symfony\Component\HttpKernel\Profiler\Profiler; use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager; -use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** @@ -194,8 +193,8 @@ class ProfilerController $url = null; try { $url = $this->generator->generate('_profiler', array('token' => $token)); - } catch (RouteNotFoundException $e) { - // the named route doesn't exist => the profiler is not enabled + } catch (\Exception $e) { + // the profiler is not enabled } return new Response($this->twig->render('@WebProfiler/Profiler/toolbar.html.twig', array( From 91635a805480bf635c9ef2aa7243c17b25524742 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 30 May 2016 10:31:06 +0200 Subject: [PATCH 08/11] Revert "bug #18908 [DependencyInjection] force enabling the external XML entity loaders (xabbuh)" This reverts commit 44f6f893083831ce9845c7d27c5e2cc855e0100b, reversing changes made to 57d6053822866a56be7d7ea1db61a69390dcc528. --- .../DependencyInjection/Loader/XmlFileLoader.php | 2 -- .../Tests/Loader/XmlFileLoaderTest.php | 13 ------------- 2 files changed, 15 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 076f4fa659..f324aa969c 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -333,9 +333,7 @@ $imports EOF ; - $disableEntities = libxml_disable_entity_loader(false); $valid = @$dom->schemaValidateSource($source); - libxml_disable_entity_loader($disableEntities); foreach ($tmpfiles as $tmpfile) { @unlink($tmpfile); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index d2e2a684a8..a8f8f35133 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -83,19 +83,6 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase $this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\SimpleXMLElement', $xml, '->parseFile() returns an SimpleXMLElement object'); } - public function testLoaderTurnsOnEntityLoaderIfNecessary() - { - $oldValue = libxml_disable_entity_loader(true); - - $containerBuilder = new ContainerBuilder(); - $loader = new XmlFileLoader($containerBuilder, new FileLocator(self::$fixturesPath.'/xml')); - $loader->load('services2.xml'); - - libxml_disable_entity_loader($oldValue); - - $this->assertTrue(count($containerBuilder->getParameterBag()->all()) > 0, 'Parameters can be read from the config file.'); - } - public function testLoadParameters() { $container = new ContainerBuilder(); From 7d8dc87616b5fe291967dd8c09cdd1dd422df517 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 May 2016 10:40:50 +0200 Subject: [PATCH 09/11] updated CHANGELOG for 2.3.42 --- CHANGELOG-2.3.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG-2.3.md b/CHANGELOG-2.3.md index 1d8ff9479e..2758f011f3 100644 --- a/CHANGELOG-2.3.md +++ b/CHANGELOG-2.3.md @@ -7,6 +7,22 @@ in 2.3 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1 +* 2.3.42 (2016-05-30) + + * bug #18908 [DependencyInjection] force enabling the external XML entity loaders (xabbuh) + * bug #18893 [DependencyInjection] Skip deep reference check for 'service_container' (RobertMe) + * bug #18812 Catch \Throwable (fprochazka) + * bug #18821 [Form] Removed UTC specification with timestamp (francisbesset) + * bug #18861 Fix for #18843 (inso) + * bug #18907 [Routing] Fix the annotation loader taking a class constant as a beginning of a class name (jakzal, nicolas-grekas) + * bug #18864 [Console][DX] Fixed ambiguous error message when using a duplicate option shortcut (peterrehm) + * bug #18844 [Yaml] fix exception contexts (xabbuh) + * bug #18840 [Yaml] properly handle unindented collections (xabbuh) + * bug #18839 People - person singularization (Keeo) + * bug #18828 [Yaml] chomp newlines only at the end of YAML documents (xabbuh) + * bug #18635 [Console] Prevent fatal error when calling Command::getHelper without helperSet (chalasr) + * bug #18761 [Form] Modified iterator_to_array's 2nd parameter to false in ViolationMapper (issei-m) + * 2.3.41 (2016-05-09) * security #18733 limited the maximum length of a submitted username (fabpot) From b4a9d258814792a89d8379975bcb14e7d2ef2914 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 May 2016 10:40:59 +0200 Subject: [PATCH 10/11] update CONTRIBUTORS for 2.3.42 --- CONTRIBUTORS.md | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d8e08d8711..94711183ff 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -23,8 +23,8 @@ Symfony is the result of the work of many people who made the code better - Pascal Borreli (pborreli) - Joseph Bielawski (stloyd) - Wouter De Jong (wouterj) - - Karma Dordrak (drak) - Romain Neutron (romain) + - Karma Dordrak (drak) - Lukas Kahwe Smith (lsmith) - Martin Hasoň (hason) - Jeremy Mikola (jmikola) @@ -53,11 +53,11 @@ Symfony is the result of the work of many people who made the code better - Bilal Amarni (bamarni) - Florin Patan (florinpatan) - Kevin Bond (kbond) + - Peter Rehm (rpet) - Gábor Egyed (1ed) - Michel Weimerskirch (mweimerskirch) - Eric Clemmons (ericclemmons) - Andrej Hudec (pulzarraider) - - Peter Rehm (rpet) - Christian Raue - Matthias Pigulla (mpdude) - Deni @@ -67,6 +67,7 @@ Symfony is the result of the work of many people who made the code better - Iltar van der Berg (kjarli) - Ener-Getick (energetick) - Douglas Greenshields (shieldo) + - Charles Sarrazin (csarrazi) - Lee McDermott - Brandon Turner - Luis Cordova (cordoval) @@ -74,7 +75,6 @@ Symfony is the result of the work of many people who made the code better - Pierre du Plessis (pierredup) - Bart van den Burg (burgov) - Jordan Alliot (jalliot) - - Charles Sarrazin (csarrazi) - John Wards (johnwards) - Toni Uebernickel (havvg) - Fran Moreno (franmomu) @@ -89,6 +89,7 @@ Symfony is the result of the work of many people who made the code better - Alexander M. Turek (derrabus) - Dariusz Ruminski - marc.weistroff + - Issei Murasawa (issei_m) - lenar - Włodzimierz Gajda (gajdaw) - Alexander Schwenn (xelaris) @@ -97,13 +98,12 @@ Symfony is the result of the work of many people who made the code better - Colin Frei - Adrien Brault (adrienbrault) - Joshua Thijssen - - Issei Murasawa (issei_m) + - Baptiste Clavié (talus) - Peter Kokot (maastermedia) - excelwebzone - Jacob Dreesen (jdreesen) - Jérémy DERUSSÉ (jderusse) - Vladimir Reznichenko (kalessil) - - Baptiste Clavié (talus) - Fabien Pennequin (fabienpennequin) - Gordon Franke (gimler) - David Buchmann (dbu) @@ -121,6 +121,7 @@ Symfony is the result of the work of many people who made the code better - Evgeniy (ewgraf) - Guilherme Blanco (guilhermeblanco) - Pablo Godel (pgodel) + - Titouan Galopin (tgalopin) - Jérémie Augustin (jaugustin) - Sebastiaan Stok (sstok) - Tugdual Saunier (tucksaun) @@ -129,10 +130,10 @@ Symfony is the result of the work of many people who made the code better - Arnaud Kleinpeter (nanocom) - Joel Wurtz (brouznouf) - Philipp Wahala (hifi) - - Titouan Galopin (tgalopin) - Richard Shank (iampersistent) - Thomas Rabaix (rande) - Vincent AUBERT (vincent) + - Rouven Weßling (realityking) - Mikael Pajunen - Clemens Tolboom - Helmer Aaviksoo @@ -143,7 +144,6 @@ Symfony is the result of the work of many people who made the code better - Amal Raghav (kertz) - Jonathan Ingram (jonathaningram) - Artur Kotyrba - - Rouven Weßling (realityking) - Warnar Boekkooi (boekkooi) - Dmitrii Chekaliuk (lazyhammer) - Clément JOBEILI (dator) @@ -211,6 +211,7 @@ Symfony is the result of the work of many people who made the code better - Kristen Gilden (kgilden) - Dawid Nowak - Pierre-Yves LEBECQ (pylebecq) + - Daniel Espendiller - Jakub Kucharovic (jkucharovic) - Eugene Leonovich (rybakit) - Filippo Tessarotto @@ -240,7 +241,6 @@ Symfony is the result of the work of many people who made the code better - Michael Holm (hollo) - Marc Weistroff (futurecat) - Hidde Wieringa (hiddewie) - - Daniel Espendiller - Chris Smith (cs278) - Florian Klein (docteurklein) - Manuel Kiessling (manuelkiessling) @@ -293,6 +293,7 @@ Symfony is the result of the work of many people who made the code better - Inal DJAFAR (inalgnu) - Christian Gärtner (dagardner) - Tomasz Kowalczyk (thunderer) + - Christian Schmidt - François-Xavier de Guillebon (de-gui_f) - Damien Alexandre (damienalexandre) - Felix Labrecque @@ -309,6 +310,7 @@ Symfony is the result of the work of many people who made the code better - Philipp Kräutli (pkraeutli) - Kirill chEbba Chebunin (chebba) - Greg Thornton (xdissent) + - Robin Chalas (chalas_r) - Costin Bereveanu (schniper) - Loïc Chardonnet (gnusat) - Marek Kalnik (marekkalnik) @@ -319,12 +321,14 @@ Symfony is the result of the work of many people who made the code better - Pavel Volokitin (pvolok) - Endre Fejes - Tobias Naumann (tna) + - Daniel Beyer - Shein Alexey - Baptiste Lafontaine - Joe Lencioni - Daniel Tschinder - Kai - Lee Rowlands + - Krzysztof Piasecki (krzysztek) - Maximilian Reichel (phramz) - Loick Piera (pyrech) - Karoly Negyesi (chx) @@ -364,7 +368,6 @@ Symfony is the result of the work of many people who made the code better - EdgarPE - Florian Pfitzer (marmelatze) - Asier Illarramendi (doup) - - Christian Schmidt - Chris Sedlmayr (catchamonkey) - Seb Koelen - Christoph Mewes (xrstf) @@ -382,6 +385,7 @@ Symfony is the result of the work of many people who made the code better - Mathieu Lemoine - franek (franek) - Christian Wahler + - Mathieu Lemoine - Gintautas Miselis - Zander Baldwin - Adam Harvey @@ -419,7 +423,6 @@ Symfony is the result of the work of many people who made the code better - Anthony Ferrara - Ioan Negulescu - Jakub Škvára (jskvara) - - Daniel Beyer - Andrew Udvare (audvare) - alexpods - Tristan Darricau (nicofuma) @@ -448,6 +451,7 @@ Symfony is the result of the work of many people who made the code better - Denis Gorbachev (starfall) - Peter van Dommelen - Tim van Densen + - Martin Morávek (keeo) - Steven Surowiec - Kevin Saliou (kbsali) - NothingWeAre @@ -462,7 +466,6 @@ Symfony is the result of the work of many people who made the code better - Ziumin - Jeremy Benoist - Lenar Lõhmus - - Krzysztof Piasecki (krzysztek) - Benjamin Laugueux (yzalis) - Zach Badgett (zachbadgett) - Aurélien Fredouelle @@ -501,6 +504,7 @@ Symfony is the result of the work of many people who made the code better - Javier López (loalf) - Reinier Kip - Dustin Dobervich (dustin10) + - dantleech - Anne-Sophie Bachelard (annesophie) - Sebastian Marek (proofek) - Erkhembayar Gantulga (erheme318) @@ -563,6 +567,7 @@ Symfony is the result of the work of many people who made the code better - Peter Ward - Dominik Ritter (dritter) - Sebastian Grodzicki (sgrodzicki) + - SpacePossum - Martin Hujer (martinhujer) - Pascal Helfenstein - Baldur Rensch (brensch) @@ -613,6 +618,7 @@ Symfony is the result of the work of many people who made the code better - Adrien Lucas (adrienlucas) - James Michael DuPont - Tom Klingenberg + - Filip Procházka (fprochazka) - Christopher Hall (mythmakr) - Paul Kamer (pkamer) - Rafał Wrzeszcz (rafalwrzeszcz) @@ -629,6 +635,7 @@ Symfony is the result of the work of many people who made the code better - Alaattin Kahramanlar (alaattin) - Maksim Kotlyar (makasim) - Neil Ferreira + - Nathanael Noblet (gnat) - Dmitry Parnas (parnas) - Théo FIDRY (theofidry) - Paul LE CORRE @@ -745,7 +752,6 @@ Symfony is the result of the work of many people who made the code better - Guillaume Royer - Artem (digi) - boite - - dantleech - Vadim Tyukov (vatson) - Sortex - chispita @@ -851,6 +857,7 @@ Symfony is the result of the work of many people who made the code better - Christian Sciberras - Anton Bakai - Clement Herreman (clemherreman) + - Dan Ionut Dumitriu (danionut90) - Nyro (nyro) - Marco - Marc Torres @@ -870,7 +877,6 @@ Symfony is the result of the work of many people who made the code better - ConneXNL - Aharon Perkel - Abdul.Mohsen B. A. A - - SpacePossum - Benoît Burnichon - Remi Collet - pthompson @@ -1059,6 +1065,7 @@ Symfony is the result of the work of many people who made the code better - stloyd - Chris Tickner - Andrew Coulton + - Jeremy Benoist - Michal Gebauer - Gleb Sidora - David Stone @@ -1108,7 +1115,6 @@ Symfony is the result of the work of many people who made the code better - Simon Sargeant - efeen - Michał Dąbrowski (defrag) - - Nathanael Noblet (gnat) - Simone Fumagalli (hpatoio) - Brian Graham (incognito) - Kevin Vergauwen (innocenzo) @@ -1214,8 +1220,10 @@ Symfony is the result of the work of many people who made the code better - Alan Chen - Maerlyn - Even André Fiskvik + - Erik van Wingerden - Dane Powell - Gerrit Drost + - Linnaea Von Lavia - Lenar Lõhmus - Cristian Gonzalez - AlberT @@ -1271,6 +1279,7 @@ Symfony is the result of the work of many people who made the code better - Joseph Deray - Damian Sromek - Ben + - dasmfm - Arnaud Buathier (arnapou) - chesteroni (chesteroni) - Mauricio Lopez (diaspar) @@ -1358,7 +1367,6 @@ Symfony is the result of the work of many people who made the code better - Norman Soetbeer - zorn - Benjamin Long - - Robin Chalas - Matt Janssen - Peter Gribanov - kwiateusz @@ -1443,6 +1451,7 @@ Symfony is the result of the work of many people who made the code better - ollie harridge (ollietb) - Paul Andrieux (paulandrieux) - Paweł Szczepanek (pauluz) + - Philippe Degeeter (pdegeeter) - Christian López Espínola (penyaskito) - Petr Jaroš (petajaros) - Philipp Hoffmann (philipphoffmann) From 7143b2974cc2b47542df987901db0e2eda33a8d5 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 May 2016 10:41:10 +0200 Subject: [PATCH 11/11] updated VERSION for 2.3.42 --- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 85df657668..7f4823220c 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -58,12 +58,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.3.42-DEV'; + const VERSION = '2.3.42'; const VERSION_ID = 20342; const MAJOR_VERSION = 2; const MINOR_VERSION = 3; const RELEASE_VERSION = 42; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; /** * Constructor.