From 0d14aac8801661b75b7a4e070f9785eddadf6f70 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Fri, 20 May 2016 15:47:36 +0200 Subject: [PATCH 01/66] 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 b38680a1bb6ec..5418f7feae919 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 @@ public function reverseTransform($value) 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/66] 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 f324aa969cc33..076f4fa659c26 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -333,7 +333,9 @@ public function validateSchema(\DOMDocument $dom) 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 a8f8f35133ae5..d2e2a684a86f8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -83,6 +83,19 @@ public function testParseFile() $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 b78fff417b249bf8e8bea34f0591864dab1d3eaa Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Thu, 26 May 2016 18:57:44 +0200 Subject: [PATCH 03/66] [Console] [SymfonyStyle] Replace long word wrapping test to directly test output --- .../Style/SymfonyStyle/command/command_11.php | 12 ++++++++++++ .../Style/SymfonyStyle/output/output_11.txt | 4 ++++ .../Console/Tests/Style/SymfonyStyleTest.php | 16 ---------------- 3 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_11.txt diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php new file mode 100644 index 0000000000000..a4ef74e79751c --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/command/command_11.php @@ -0,0 +1,12 @@ +block($word, 'CUSTOM', 'fg=white;bg=blue', ' § ', false); +}; diff --git a/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_11.txt b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_11.txt new file mode 100644 index 0000000000000..190d784035476 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/Style/SymfonyStyle/output/output_11.txt @@ -0,0 +1,4 @@ + + § [CUSTOM] Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophatto + § peristeralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon + diff --git a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php index 889a9c82f2dcb..e4ce037bb8f16 100644 --- a/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php +++ b/src/Symfony/Component/Console/Tests/Style/SymfonyStyleTest.php @@ -54,22 +54,6 @@ public function inputCommandToOutputFilesProvider() return array_map(null, glob($baseDir.'/command/command_*.php'), glob($baseDir.'/output/output_*.txt')); } - - public function testLongWordsBlockWrapping() - { - $word = 'Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygovgollhjvhvljfezefeqifzeiqgiqzhrsdgihqzridghqridghqirshdghdghieridgheirhsdgehrsdvhqrsidhqshdgihrsidvqhneriqsdvjzergetsrfhgrstsfhsetsfhesrhdgtesfhbzrtfbrztvetbsdfbrsdfbrn'; - $wordLength = strlen($word); - $maxLineLength = SymfonyStyle::MAX_LINE_LENGTH - 3; - - $this->command->setCode(function (InputInterface $input, OutputInterface $output) use ($word) { - $sfStyle = new SymfonyStyleWithForcedLineLength($input, $output); - $sfStyle->block($word, 'CUSTOM', 'fg=white;bg=blue', ' § ', false); - }); - - $this->tester->execute(array(), array('interactive' => false, 'decorated' => false)); - $expectedCount = (int) ceil($wordLength / ($maxLineLength)) + (int) ($wordLength > $maxLineLength - 5); - $this->assertSame($expectedCount, substr_count($this->tester->getDisplay(true), ' § ')); - } } /** From 76e30a988193a3b51b8580d440531a54b02dd3fa Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 May 2016 09:57:32 +0200 Subject: [PATCH 04/66] bumped Symfony version to 3.1.1 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index c26ee931803a9..9657138b6abff 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -59,12 +59,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '3.1.0'; - const VERSION_ID = 30100; + const VERSION = '3.1.1-DEV'; + const VERSION_ID = 30101; const MAJOR_VERSION = 3; const MINOR_VERSION = 1; - const RELEASE_VERSION = 0; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 1; + const EXTRA_VERSION = 'DEV'; const END_OF_MAINTENANCE = '01/2017'; const END_OF_LIFE = '07/2017'; From 7d78196d0c25188eb3c16c9f0fc7cfa2706612c7 Mon Sep 17 00:00:00 2001 From: Anton Bakai Date: Tue, 24 May 2016 23:58:05 +0300 Subject: [PATCH 05/66] 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 21351a5c34fc9..9bd9389c07483 100644 --- a/src/Symfony/Component/Yaml/Dumper.php +++ b/src/Symfony/Component/Yaml/Dumper.php @@ -58,7 +58,7 @@ public function dump($input, $inline = 0, $indent = 0, $exceptionOnInvalidType = 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 5f15e3c5b4a9b..0ce1ced7d7ab8 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -145,6 +145,28 @@ public static function dump($value, $exceptionOnInvalidType = false, $objectSupp } } + /** + * 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 @@ public static function dump($value, $exceptionOnInvalidType = false, $objectSupp 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 @@ private static function dumpArray($value, $exceptionOnInvalidType, $objectSuppor 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 255928d16d2cd..b1263d8d290bb 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -169,6 +169,24 @@ public function testParseUnquotedAsteriskFollowedByAComment() 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 @@ protected function getTestsForDump() '[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 06/66] [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 f8f17b4f723e6..352ba584a7638 100644 --- a/src/Symfony/Component/Serializer/Encoder/ChainDecoder.php +++ b/src/Symfony/Component/Serializer/Encoder/ChainDecoder.php @@ -59,7 +59,7 @@ public function supportsDecoding($format) * * @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 be788ee7c51ff..3b3e478e7b494 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 1ac6a17180247..662a087ad4284 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 6a2b5cf452dde..247cb9382b917 100644 --- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php @@ -399,6 +399,8 @@ private function needsCdataWrapping($val) * @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 55c030c7c4fa7..b3bbf50a6db91 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 8b6c2333958fe..40c5890bd35ea 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 79cba123fffb3..9f323b9d0c2a9 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 2a51d631b1624..0ce5b3aef2520 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 c3e07e821c023..6160b5205cde5 100644 --- a/src/Symfony/Component/Serializer/Serializer.php +++ b/src/Symfony/Component/Serializer/Serializer.php @@ -169,6 +169,8 @@ public function supportsDenormalization($data, $type, $format = null) /** * {@inheritdoc} + * + * @throws RuntimeException */ private function getNormalizer($data, $format = null) { @@ -183,6 +185,8 @@ private function getNormalizer($data, $format = null) /** * {@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 c79db91892075..ed2e71c2cd03f 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 @@ public function serialize($data, $format, array $context = array()); * @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 07/66] 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 b37bee83d401c..801149372af99 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php @@ -77,6 +77,9 @@ public function load($resource, $type = null) } catch (\Exception $e) { $this->loading = false; throw $e; + } catch (\Throwable $e) { + $this->loading = false; + throw $e; } $this->loading = false; @@ -85,7 +88,7 @@ public function load($resource, $type = null) 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 173616fd9f500..a152313df9899 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -18,6 +18,7 @@ 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 @@ public function toolbarAction(Request $request, $token) $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 9c1b4d9f1eaf6..f25d477069e51 100644 --- a/src/Symfony/Component/Config/Loader/FileLoader.php +++ b/src/Symfony/Component/Config/Loader/FileLoader.php @@ -108,6 +108,9 @@ public function import($resource, $type = null, $ignoreErrors = false, $sourceRe } 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 9243b66c8e421..084c4da6fef7f 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -320,6 +320,11 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE 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 ad2f89ae77d0d..7c60f0a7d42bb 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -461,6 +461,10 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV 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 c9b8a211d4291..e288720b977b9 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php @@ -64,6 +64,11 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ $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 08/66] [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 d239b7d7d509e..d7ab4fc2b83fe 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -1173,7 +1173,7 @@ private function hasReference($id, array $arguments, $deep = false, &$visited = 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 311026c5e62d5..219ea63e82fd5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -226,4 +226,15 @@ public function testCircularReference() $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 0000000000000..0c33b7b3eab8d --- /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 09/66] 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 a152313df9899..173616fd9f500 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -18,7 +18,6 @@ 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 @@ public function toolbarAction(Request $request, $token) $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 240cf0aaa8d8bbb0180ed1c762709741cb1a65b9 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 30 May 2016 10:20:49 +0200 Subject: [PATCH 10/66] [#18838] add a test to avoid regressions --- .../Tests/Normalizer/ObjectNormalizerTest.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php index 5d91a9fd1e056..8a09e516cd230 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -545,6 +545,28 @@ public function testRejectInvalidType() $serializer->denormalize(array('date' => 'foo'), ObjectOuter::class); } + + public function testExtractAttributesRespectsFormat() + { + $normalizer = new FormatAndContextAwareNormalizer(); + + $data = new ObjectDummy(); + $data->setFoo('bar'); + $data->bar = 'foo'; + + $this->assertSame(array('foo' => 'bar', 'bar' => 'foo'), $normalizer->normalize($data, 'foo_and_bar_included')); + } + + public function testExtractAttributesRespectsContext() + { + $normalizer = new FormatAndContextAwareNormalizer(); + + $data = new ObjectDummy(); + $data->setFoo('bar'); + $data->bar = 'foo'; + + $this->assertSame(array('foo' => 'bar', 'bar' => 'foo'), $normalizer->normalize($data, null, array('include_foo_and_bar' => true))); + } } class ObjectDummy @@ -744,3 +766,19 @@ class ObjectInner public $foo; public $bar; } + +class FormatAndContextAwareNormalizer extends ObjectNormalizer +{ + protected function isAllowedAttribute($classOrObject, $attribute, $format = null, array $context = array()) + { + if (in_array($attribute, array('foo', 'bar')) && 'foo_and_bar_included' === $format) { + return true; + } + + if (in_array($attribute, array('foo', 'bar')) && isset($context['include_foo_and_bar']) && true === $context['include_foo_and_bar']) { + return true; + } + + return false; + } +} From 91635a805480bf635c9ef2aa7243c17b25524742 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 30 May 2016 10:31:06 +0200 Subject: [PATCH 11/66] 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 076f4fa659c26..f324aa969cc33 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -333,9 +333,7 @@ public function validateSchema(\DOMDocument $dom) 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 d2e2a684a86f8..a8f8f35133ae5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -83,19 +83,6 @@ public function testParseFile() $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 12/66] 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 1d8ff9479ecca..2758f011f3cfd 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 13/66] 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 d8e08d87119b7..94711183ff113 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 14/66] 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 85df657668bff..7f4823220c075 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. From d14f0bf71f787c60ce742325531e82e02e024485 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 31 May 2016 21:27:35 +0200 Subject: [PATCH 15/66] add missing hint for vote() argument type --- UPGRADE-3.0.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 8c509b36f0dcc..2dd04e8b64195 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -1042,6 +1042,9 @@ UPGRADE FROM 2.x to 3.0 introduced in 2.8, and move your voting logic to the to the `supports($attribute, $subject)` and `voteOnAttribute($attribute, $object, TokenInterface $token)` methods. + * The `vote()` method from the `VoterInterface` was changed to now accept arbitrary + types, and not only objects. + * The `supportsClass` and `supportsAttribute` methods were removed from the `VoterInterface` interface. From c0b9e9950a55e668fcd5a9d0d0977baadca59d99 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 31 May 2016 21:30:07 +0200 Subject: [PATCH 16/66] document method name changes in Voter class --- UPGRADE-3.0.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 265724627c2ae..08796bd419d29 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -1040,6 +1040,39 @@ UPGRADE FROM 2.x to 3.0 } ``` + * The `AbstractVoter::isGranted()` method has been replaced by `Voter::voteOnAttribute()`. + + Before: + + ```php + class MyVoter extends AbstractVoter + { + protected function isGranted($attribute, $object, $user = null) + { + return 'EDIT' === $attribute && $user === $object->getAuthor(); + } + + // ... + } + ``` + + After: + + ```php + class MyVoter extends Voter + { + protected function voteOnAttribute($attribute, $object, TokenInterface $token) + { + return 'EDIT' === $attribute && $token->getUser() === $object->getAuthor(); + } + + // ... + } + ``` + + * The `supportsAttribute()` and `supportsClass()` methods of the `AuthenticatedVoter`, `ExpressionVoter`, + and `RoleVoter` classes have been removed. + * The `intention` option was renamed to `csrf_token_id` for all the authentication listeners. * The `csrf_provider` option was renamed to `csrf_token_generator` for all the authentication listeners. From 7a5a1391357c56e347b9fb1bd14153c12976a833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Tue, 31 May 2016 18:12:47 +0200 Subject: [PATCH 17/66] [Console] Fix BC break introduced by #18101 --- .../DependencyInjection/Compiler/AddConsoleCommandPass.php | 2 +- .../DependencyInjection/Compiler/AddConsoleCommandPassTest.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php index 09e8948ded0f3..6c20c83af106f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php @@ -38,7 +38,7 @@ public function process(ContainerBuilder $container) throw new \InvalidArgumentException(sprintf('The service "%s" tagged "console.command" must be a subclass of "Symfony\\Component\\Console\\Command\\Command".', $id)); } $container->setAlias($serviceId = 'console.command.'.strtolower(str_replace('\\', '_', $class)), $id); - $serviceIds[] = $serviceId; + $serviceIds[] = $definition->isPublic() ? $id : $serviceId; } $container->setParameter('console.command.ids', $serviceIds); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php index 72902c99cd4d0..d488405544d32 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php @@ -45,8 +45,9 @@ public function testProcess($public) $this->assertTrue($container->hasDefinition($alias)); } + $id = $public ? 'my-command' : 'console.command.symfony_bundle_frameworkbundle_tests_dependencyinjection_compiler_mycommand'; $this->assertTrue($container->hasParameter('console.command.ids')); - $this->assertSame(array('console.command.symfony_bundle_frameworkbundle_tests_dependencyinjection_compiler_mycommand'), $container->getParameter('console.command.ids')); + $this->assertSame(array($id), $container->getParameter('console.command.ids')); } public function visibilityProvider() From c1df9f210e53a9155343159a820e320a76d35582 Mon Sep 17 00:00:00 2001 From: Dword123 Date: Wed, 1 Jun 2016 13:20:21 +0200 Subject: [PATCH 18/66] Improve memory efficiency This avoids concatenating `$message` and `PHP_EOL` (if necessary) as a new value, greatly improving memory efficiency for large `$message`s. --- src/Symfony/Component/Console/Output/StreamOutput.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Output/StreamOutput.php b/src/Symfony/Component/Console/Output/StreamOutput.php index 80c352a278671..f3708ecffe526 100644 --- a/src/Symfony/Component/Console/Output/StreamOutput.php +++ b/src/Symfony/Component/Console/Output/StreamOutput.php @@ -70,7 +70,7 @@ public function getStream() */ protected function doWrite($message, $newline) { - if (false === @fwrite($this->stream, $message.($newline ? PHP_EOL : ''))) { + if (false === @fwrite($this->stream, $message) || ($newline && (false === @fwrite($this->stream, PHP_EOL)))) { // should never happen throw new \RuntimeException('Unable to write output.'); } From 71dcaa14c927d84ff2ed5d88e76fe55f5454e807 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Wed, 1 Jun 2016 21:19:49 +0200 Subject: [PATCH 19/66] Add 3.1 to PR template branch row, remove 2.3 --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 7ed7b20e228ae..71c775edb8ae7 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ | Q | A | ------------- | --- -| Branch? | "master" for new features / 2.3, 2.7, 2.8 or 3.0 for fixes +| Branch? | "master" for new features / 2.7, 2.8, 3.0 or 3.1 for fixes | Bug fix? | yes/no | New feature? | yes/no | BC breaks? | yes/no From 58996ac0bf6fe14251a9842c6a66d8ff4c3c29bb Mon Sep 17 00:00:00 2001 From: Charles Sarrazin Date: Wed, 1 Jun 2016 21:35:13 +0200 Subject: [PATCH 20/66] Fixed issue with missing argument in the abstract service definition for the ldap user provider --- src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml index d19ae1eab81dd..930616901064a 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml @@ -127,6 +127,7 @@ + From bff9c3631d2a2057fe14eca001da7af59f62db21 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 1 Jun 2016 23:22:27 +0200 Subject: [PATCH 21/66] LdapUserProvider: add missing argument type doc --- src/Symfony/Component/Security/Core/User/LdapUserProvider.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Component/Security/Core/User/LdapUserProvider.php b/src/Symfony/Component/Security/Core/User/LdapUserProvider.php index e722c98e6d687..5eb7668dac1f8 100644 --- a/src/Symfony/Component/Security/Core/User/LdapUserProvider.php +++ b/src/Symfony/Component/Security/Core/User/LdapUserProvider.php @@ -42,6 +42,7 @@ class LdapUserProvider implements UserProviderInterface * @param array $defaultRoles * @param string $uidKey * @param string $filter + * @param string $passwordAttribute */ public function __construct(LdapInterface $ldap, $baseDn, $searchDn = null, $searchPassword = null, array $defaultRoles = array(), $uidKey = 'sAMAccountName', $filter = '({uid_key}={username})', $passwordAttribute = null) { From e041da09e45960e941e39ae1ee744f287f85e251 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Thu, 2 Jun 2016 08:29:41 +0200 Subject: [PATCH 22/66] Use the Trusty Travis infrastructure for HHVM builds This allows running an uptodate version of HHVM rather than running the latest version supporting Precise, which is very old. --- .travis.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index a48fa8a353035..1011535020f30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,11 @@ env: matrix: include: + # Use the newer stack for HHVM as HHVM does not support Precise anymore since a long time and so Precise has an outdated version - php: hhvm + sudo: required + dist: trusty + group: edge - php: 5.3 - php: 5.4 - php: 5.5 @@ -37,10 +41,10 @@ services: mongodb before_install: - PHP=$TRAVIS_PHP_VERSION # Matrix lines for intermediate PHP versions are skipped for pull requests - - if [[ ! $deps && ! $PHP = ${MIN_PHP%.*} && $PHP != hhvm && $TRAVIS_PULL_REQUEST != false ]]; then deps=skip; skip=1; fi + - if [[ ! $deps && ! $PHP = ${MIN_PHP%.*} && ! $PHP = hhvm* && $TRAVIS_PULL_REQUEST != false ]]; then deps=skip; skip=1; fi # A sigchild-enabled-PHP is used to test the Process component on the lowest PHP matrix line - if [[ ! $deps && $PHP = ${MIN_PHP%.*} && ! -d php-$MIN_PHP/sapi ]]; then wget http://museum.php.net/php5/php-$MIN_PHP.tar.bz2 -O - | tar -xj; (cd php-$MIN_PHP; ./configure --enable-sigchild --enable-pcntl; make -j2); fi - - if [[ $PHP != hhvm ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi + - if [[ ! $PHP = hhvm* ]]; then INI_FILE=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; else INI_FILE=/etc/hhvm/php.ini; fi - if [[ ! $skip ]]; then echo memory_limit = -1 >> $INI_FILE; fi - if [[ ! $skip ]]; then echo session.gc_probability = 0 >> $INI_FILE; fi - if [[ ! $skip && $PHP = 5.* ]]; then echo extension = mongo.so >> $INI_FILE; fi @@ -49,8 +53,8 @@ before_install: - if [[ ! $skip && $PHP = 7.* ]]; then (echo yes | pecl install -f apcu-5.1.2 && echo apc.enable_cli = 1 >> $INI_FILE); fi - if [[ ! $deps && $PHP = 5.* ]]; then (cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo extension = $(pwd)/modules/symfony_debug.so >> $INI_FILE); fi - if [[ ! $skip && $PHP = 5.* ]]; then pecl install -f memcached-2.1.0; fi - - if [[ ! $skip && $PHP != hhvm ]]; then echo extension = ldap.so >> $INI_FILE; fi - - if [[ ! $skip && $PHP != hhvm ]]; then phpenv config-rm xdebug.ini; fi + - if [[ ! $skip && ! $PHP = hhvm* ]]; then echo extension = ldap.so >> $INI_FILE; fi + - if [[ ! $skip && ! $PHP = hhvm* ]]; then phpenv config-rm xdebug.ini; fi - if [[ ! $skip ]]; then composer self-update --stable; fi - if [[ ! $skip ]]; then cp .composer/* ~/.composer/; fi - if [[ ! $skip ]]; then ./phpunit install; fi @@ -68,7 +72,7 @@ install: - export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev - if [[ ! $deps ]]; then composer update; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi - if [[ $TRAVIS_BRANCH = master ]]; then export SYMFONY_PHPUNIT_OVERLOAD=1; fi - - if [[ $PHP != hhvm ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi + - if [[ ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi script: - if [[ $skip ]]; then echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"; fi From e6956c9bfc25d892107648f005850582d289c6f0 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Thu, 2 Jun 2016 10:18:15 +0200 Subject: [PATCH 23/66] Skip some tests on HHVM due to a PHPunit bug --- .../Storage/Handler/MemcacheSessionHandlerTest.php | 4 ++++ .../Storage/Handler/MemcachedSessionHandlerTest.php | 4 ++++ .../Session/Storage/Handler/PdoSessionHandlerTest.php | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php index e8795244b176e..0c579d7724846 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcacheSessionHandlerTest.php @@ -30,6 +30,10 @@ class MemcacheSessionHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { + if (defined('HHVM_VERSION')) { + $this->markTestSkipped('PHPUnit_MockObject cannot mock the Memcache class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289'); + } + parent::setUp(); $this->memcache = $this->getMock('Memcache'); $this->storage = new MemcacheSessionHandler( diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php index f51ec8ed63c86..75e4a20e2a8d5 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php @@ -31,6 +31,10 @@ class MemcachedSessionHandlerTest extends \PHPUnit_Framework_TestCase protected function setUp() { + if (defined('HHVM_VERSION')) { + $this->markTestSkipped('PHPUnit_MockObject cannot mock the Memcached class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289'); + } + parent::setUp(); if (version_compare(phpversion('memcached'), '2.2.0', '>=')) { diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index 1af321096ebad..9612320976944 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -135,6 +135,10 @@ public function testReadWriteReadWithNullByte() public function testReadConvertsStreamToString() { + if (defined('HHVM_VERSION')) { + $this->markTestSkipped('PHPUnit_MockObject cannot mock the PDOStatement class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289'); + } + $pdo = new MockPdo('pgsql'); $pdo->prepareResult = $this->getMock('PDOStatement'); @@ -152,6 +156,10 @@ public function testReadConvertsStreamToString() public function testReadLockedConvertsStreamToString() { + if (defined('HHVM_VERSION')) { + $this->markTestSkipped('PHPUnit_MockObject cannot mock the PDOStatement class on HHVM. See https://github.com/sebastianbergmann/phpunit-mock-objects/pull/289'); + } + $pdo = new MockPdo('pgsql'); $selectStmt = $this->getMock('PDOStatement'); $insertStmt = $this->getMock('PDOStatement'); From ff2d189f348e72f25c3169a67a826acc1944cca2 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Thu, 2 Jun 2016 13:03:22 +0200 Subject: [PATCH 24/66] [Security] Fix DebugAccessDecisionManager when object is not a scalar --- .../DebugAccessDecisionManager.php | 9 +++- .../DebugAccessDecisionManagerTest.php | 43 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Component/Security/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php diff --git a/src/Symfony/Component/Security/Core/Authorization/DebugAccessDecisionManager.php b/src/Symfony/Component/Security/Core/Authorization/DebugAccessDecisionManager.php index 7c0cfc9340f49..540d998206047 100644 --- a/src/Symfony/Component/Security/Core/Authorization/DebugAccessDecisionManager.php +++ b/src/Symfony/Component/Security/Core/Authorization/DebugAccessDecisionManager.php @@ -103,7 +103,14 @@ private function getStringRepresentation($object) } if (!is_object($object)) { - return sprintf('%s (%s)', gettype($object), $object); + if (is_bool($object)) { + return sprintf('%s (%s)', gettype($object), $object ? 'true' : 'false'); + } + if (is_scalar($object)) { + return sprintf('%s (%s)', gettype($object), $object); + } + + return gettype($object); } $objectClass = class_exists('Doctrine\Common\Util\ClassUtils') ? ClassUtils::getClass($object) : get_class($object); diff --git a/src/Symfony/Component/Security/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php b/src/Symfony/Component/Security/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php new file mode 100644 index 0000000000000..f90f7769ba4c9 --- /dev/null +++ b/src/Symfony/Component/Security/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Security\Core\Tests\Authorization; + +use Symfony\Component\Security\Core\Authorization\AccessDecisionManager; +use Symfony\Component\Security\Core\Authorization\DebugAccessDecisionManager; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + +class DebugAccessDecisionManagerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider provideObjectsAndLogs + */ + public function testDecideLog($expectedLog, $object) + { + $adm = new DebugAccessDecisionManager(new AccessDecisionManager()); + $adm->decide($this->getMock(TokenInterface::class), array('ATTRIBUTE_1'), $object); + + $this->assertSame($expectedLog, $adm->getDecisionLog()); + } + + public function provideObjectsAndLogs() + { + $object = new \stdClass(); + + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'NULL', 'result' => false)), null); + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'boolean (true)', 'result' => false)), true); + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'string (jolie string)', 'result' => false)), 'jolie string'); + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'integer (12345)', 'result' => false)), 12345); + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'resource', 'result' => false)), fopen(__FILE__, 'r')); + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => 'array', 'result' => false)), array()); + yield array(array(array('attributes' => array('ATTRIBUTE_1'), 'object' => sprintf('stdClass (object hash: %s)', spl_object_hash($object)), 'result' => false)), $object); + } +} From 078c8b6b8a179f12f61917ce5c75d409e5649bed Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Fri, 3 Jun 2016 02:46:43 +0200 Subject: [PATCH 25/66] Fixed forwarded request data in templates --- .../Resources/views/Collector/request.html.twig | 4 ++-- .../Resources/views/Profiler/layout.html.twig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig index 18f20834f08f3..136e9db9e7dd8 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig @@ -13,7 +13,7 @@ {% endset %} {% endif %} - {% if collector.forward %} + {% if collector.forward|default(false) %} {% set forward_handler %} {% import _self as helper %} {{ helper.set_handler(collector.forward.controller) }} @@ -26,7 +26,7 @@ {{ collector.statuscode }} {% if collector.route %} {% if collector.redirect %}{{ include('@WebProfiler/Icon/redirect.svg') }}{% endif %} - {% if collector.forward %}{{ include('@WebProfiler/Icon/forward.svg') }}{% endif %} + {% if collector.forward|default(false) %}{{ include('@WebProfiler/Icon/forward.svg') }}{% endif %} {{ 'GET' != collector.method ? collector.method }} @ {{ collector.route }} {% endif %} diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig index 7193158b2b802..3207b3c95a4b2 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig @@ -44,7 +44,7 @@ {%- endif %} - {% if request_collector and request_collector.forward and request_collector.forward.controller.class is defined -%} + {% if request_collector and request_collector.forward|default(false) and request_collector.forward.controller.class is defined -%} {%- set forward = request_collector.forward -%} {%- set controller = forward.controller -%}