From 3cc4e4d0d437b5573a0a293406b55d39af646c50 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 28 Dec 2015 15:56:15 +0100 Subject: [PATCH 01/10] add missing symfony/polyfill-php55 dependency The `json_last_error_msg()` function used in the `JsonResponse` class requires PHP 5.5. --- src/Symfony/Component/HttpFoundation/composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/composer.json b/src/Symfony/Component/HttpFoundation/composer.json index 55edbbf6fd..e8733d840e 100644 --- a/src/Symfony/Component/HttpFoundation/composer.json +++ b/src/Symfony/Component/HttpFoundation/composer.json @@ -17,7 +17,8 @@ ], "require": { "php": ">=5.3.9", - "symfony/polyfill-php54": "~1.0" + "symfony/polyfill-php54": "~1.0", + "symfony/polyfill-php55": "~1.0" }, "require-dev": { "symfony/expression-language": "~2.4|~3.0.0" From bd686cd1eecad01e38794bf4ee65566e24f844b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Tue, 29 Dec 2015 03:17:50 +0100 Subject: [PATCH 02/10] [Form] Fixed regression on Collection type --- .../Component/Form/Extension/Core/Type/CollectionType.php | 2 +- .../Form/Tests/Extension/Core/Type/CollectionTypeTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php b/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php index 1055b73559..cba25016a0 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php @@ -30,7 +30,7 @@ class CollectionType extends AbstractType $prototypeOptions = array_replace(array( 'required' => $options['required'], 'label' => $options['prototype_name'].'label__', - ), $options['options']); + ), $options['entry_options']); if (null !== $options['prototype_data']) { $prototypeOptions['data'] = $options['prototype_data']; diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php index 45c56e1075..c3416a8395 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php @@ -311,10 +311,12 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'entry_options' => array( 'data' => 'bar', + 'label' => false, ), )); $this->assertSame('foo', $form->createView()->vars['prototype']->vars['value']); + $this->assertFalse($form->createView()->vars['prototype']->vars['label']); } /** @@ -328,9 +330,11 @@ class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextType', 'options' => array( 'data' => 'bar', + 'label' => false, ), )); $this->assertSame('bar', $form->createView()->vars['prototype']->vars['value']); + $this->assertFalse($form->createView()->vars['prototype']->vars['label']); } public function testPrototypeDefaultRequired() From 787853673bc12d0d147c0968ebc5a633880514bf Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Wed, 23 Dec 2015 11:40:24 +0100 Subject: [PATCH 03/10] [Form] improve deprecation messages for the "empty_value" and "choice_list" options in the ChoiceType class. --- .../Component/Form/Extension/Core/Type/ChoiceType.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 1465551b90..ced8fc3f43 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -292,9 +292,10 @@ class ChoiceType extends AbstractType return; }; - $choiceListNormalizer = function (Options $options, $choiceList) use ($choiceListFactory) { + $that = $this; + $choiceListNormalizer = function (Options $options, $choiceList) use ($choiceListFactory, $that) { if ($choiceList) { - @trigger_error('The "choice_list" option is deprecated since version 2.7 and will be removed in 3.0. Use "choice_loader" instead.', E_USER_DEPRECATED); + @trigger_error(sprintf('The "choice_list" option of the "%s" form type (%s) is deprecated since version 2.7 and will be removed in 3.0. Use "choice_loader" instead.', $that->getName(), __CLASS__), E_USER_DEPRECATED); if ($choiceList instanceof LegacyChoiceListInterface) { return new LegacyChoiceListAdapter($choiceList); @@ -321,9 +322,9 @@ class ChoiceType extends AbstractType return $choiceListFactory->createListFromChoices($choices, $options['choice_value']); }; - $placeholderNormalizer = function (Options $options, $placeholder) { + $placeholderNormalizer = function (Options $options, $placeholder) use ($that) { if (!is_object($options['empty_value']) || !$options['empty_value'] instanceof \Exception) { - @trigger_error('The form option "empty_value" is deprecated since version 2.6 and will be removed in 3.0. Use "placeholder" instead.', E_USER_DEPRECATED); + @trigger_error(sprintf('The form option "empty_value" of the "%s" form type (%s) is deprecated since version 2.6 and will be removed in 3.0. Use "placeholder" instead.', $that->getName(), __CLASS__), E_USER_DEPRECATED); $placeholder = $options['empty_value']; } From ba7213c28067d3f0f8b91213096d410dc5a5b63e Mon Sep 17 00:00:00 2001 From: Hugo Hamon Date: Tue, 29 Dec 2015 17:31:38 +0100 Subject: [PATCH 04/10] [DependencyInjection] fixes typo in triggered deprecation notice. --- src/Symfony/Component/DependencyInjection/SimpleXMLElement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/SimpleXMLElement.php b/src/Symfony/Component/DependencyInjection/SimpleXMLElement.php index 63d44ea38f..87c67c4d7e 100644 --- a/src/Symfony/Component/DependencyInjection/SimpleXMLElement.php +++ b/src/Symfony/Component/DependencyInjection/SimpleXMLElement.php @@ -11,7 +11,7 @@ namespace Symfony\Component\DependencyInjection; -@trigger_error('The '.__NAMESPACE__.'\SimpleXMLElement method is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); +@trigger_error('The '.__NAMESPACE__.'\SimpleXMLElement class is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED); use Symfony\Component\Config\Util\XmlUtils; use Symfony\Component\ExpressionLanguage\Expression; From 6215437bdd6d6fc67ee167aea5e88324117be668 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 29 Dec 2015 16:09:05 +0100 Subject: [PATCH 05/10] [travis] use github token to fetch deps from ZIP files --- .composer-auth.json | 7 +++++++ .travis.yml | 7 ++++--- appveyor.yml | 4 +++- phpunit | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 .composer-auth.json diff --git a/.composer-auth.json b/.composer-auth.json new file mode 100644 index 0000000000..bf40540cc6 --- /dev/null +++ b/.composer-auth.json @@ -0,0 +1,7 @@ +{ + "github-oauth": { + "github.com": "PLEASE DO NOT USE THIS TOKEN IN YOUR OWN PROJECTS/FORKS", + "github.com": "This token is reserved for testing the symfony/symfony repository", + "github.com": "52270bad1071a099c8d24629f2db2b7f07db960d" + } +} diff --git a/.travis.yml b/.travis.yml index 2ada5b2ea5..46a2109589 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,6 +42,7 @@ before_install: - if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then pecl install -f memcached-2.1.0 || echo "Let's continue without memcached extension"; fi; - if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then echo extension = ldap.so >> $INI_FILE; fi; - if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then phpenv config-rm xdebug.ini; fi; + - if [[ $TRAVIS_REPO_SLUG = symfony/symfony ]]; then cp .composer-auth.json ~/.composer/auth.json; fi; - if [[ $deps != skip ]]; then composer self-update; fi; - if [[ $deps != skip ]]; then ./phpunit install; fi; - export PHPUNIT=$(readlink -f ./phpunit) @@ -53,13 +54,13 @@ install: - if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; fi; - if [[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]]; then LEGACY=,legacy; fi; - export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev; - - if [[ ! $deps ]]; then composer --prefer-source install; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi; + - if [[ ! $deps ]]; then composer update --prefer-dist; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi; - if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi; script: - if [[ ! $deps ]]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi; - if [[ ! $deps ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi; - if [[ ! $deps && $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | parallel --gnu --timeout 60 'echo -e "\\nPHP --enable-sigchild enhanced={}" && ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi; - - if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer --prefer-source update; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY; fi; - - if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi; + - if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --prefer-dist; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY; fi; + - if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --prefer-dist --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi; - if [[ $deps = skip ]]; then echo This matrix line is skipped for pull requests.; fi; diff --git a/appveyor.yml b/appveyor.yml index 9ae51aca0a..61e8b56353 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -49,9 +49,11 @@ install: - appveyor DownloadFile https://getcomposer.org/composer.phar - copy /Y php.ini-max php.ini - cd c:\projects\symfony + - mkdir %APPDATA%\Composer + - IF %APPVEYOR_REPO_NAME%==symfony/symfony copy /Y .composer-auth.json %APPDATA%\Composer\auth.json - php phpunit install - IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev) - - composer update --prefer-source --no-progress --ansi + - composer update --prefer-dist --no-progress --ansi test_script: - cd c:\projects\symfony diff --git a/phpunit b/phpunit index 146ab9d376..0517719add 100755 --- a/phpunit +++ b/phpunit @@ -53,7 +53,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__ chdir("phpunit-$PHPUNIT_VERSION"); passthru("$COMPOSER remove --no-update symfony/yaml"); passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=2.8@dev\""); - passthru("$COMPOSER install --prefer-source --no-progress --ansi"); + passthru("$COMPOSER install --prefer-dist --no-progress --ansi"); file_put_contents('phpunit', << Date: Tue, 29 Dec 2015 18:08:17 +0100 Subject: [PATCH 06/10] [Routing] removed unused variable in PhpMatcherDumperTest class. --- .../Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php index 1b2dee688d..2be631cf09 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php @@ -167,8 +167,6 @@ class PhpMatcherDumperTest extends \PHPUnit_Framework_TestCase $route1 = new Route('/route1', array(), array(), array(), 'a.example.com'); $collection1->add('route1', $route1); - $collection2 = new RouteCollection(); - $route2 = new Route('/c2/route2', array(), array(), array(), 'a.example.com'); $collection1->add('route2', $route2); From ceded10f675b370c9914f47093878f81b8cd08dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 28 Dec 2015 11:54:34 +0100 Subject: [PATCH 07/10] [DoctrineBridge] [PropertyInfo] Catch Doctrine\ORM\Mapping\MappingException --- .../Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php | 5 +++++ .../Tests/PropertyInfo/DoctrineExtractorTest.php | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php index dc22e23595..6e330e558a 100644 --- a/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php +++ b/src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php @@ -14,6 +14,7 @@ namespace Symfony\Bridge\Doctrine\PropertyInfo; use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory; use Doctrine\Common\Persistence\Mapping\MappingException; use Doctrine\ORM\Mapping\ClassMetadataInfo; +use Doctrine\ORM\Mapping\MappingException as OrmMappingException; use Symfony\Component\PropertyInfo\PropertyListExtractorInterface; use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; use Symfony\Component\PropertyInfo\Type; @@ -44,6 +45,8 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE $metadata = $this->classMetadataFactory->getMetadataFor($class); } catch (MappingException $exception) { return; + } catch (OrmMappingException $exception) { + return; } return array_merge($metadata->getFieldNames(), $metadata->getAssociationNames()); @@ -58,6 +61,8 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE $metadata = $this->classMetadataFactory->getMetadataFor($class); } catch (MappingException $exception) { return; + } catch (OrmMappingException $exception) { + return; } if ($metadata->hasAssociation($property)) { diff --git a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php index df6c355895..376208088c 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php @@ -81,4 +81,14 @@ class DoctrineExtractorTest extends \PHPUnit_Framework_TestCase array('notMapped', null), ); } + + public function testGetPropertiesCatchException() + { + $this->assertNull($this->extractor->getProperties('Not\Exist')); + } + + public function testGetTypesCatchException() + { + $this->assertNull($this->extractor->getTypes('Not\Exist', 'baz')); + } } From 99fc428bdcbb9d0e6ab9e6487fc458becd200d3a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 30 Dec 2015 09:46:06 +0100 Subject: [PATCH 08/10] [Process] Fix potential race condition leading to transient tests --- src/Symfony/Component/Process/Process.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index b2af092747..c7c536b766 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1072,13 +1072,10 @@ class Process $callback = $this->callback; foreach ($result as $type => $data) { - if (3 === $type) { - $this->fallbackStatus['running'] = false; - if (!isset($this->fallbackStatus['signaled'])) { - $this->fallbackStatus['exitcode'] = (int) $data; - } - } else { + if (3 !== $type) { $callback($type === self::STDOUT ? self::OUT : self::ERR, $data); + } elseif (!isset($this->fallbackStatus['signaled'])) { + $this->fallbackStatus['exitcode'] = (int) $data; } } } From 7e2c67c9dc4f85ff12b0711608c27a4a3f4af3f7 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 30 Dec 2015 09:37:09 +0100 Subject: [PATCH 09/10] [Process] Fix a transient test --- src/Symfony/Component/Process/Tests/ProcessTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 4a5a38cd85..8a40860afc 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -193,7 +193,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase fwrite($stream, $expected); rewind($stream); - $p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg($code)), null, null, null, 5); + $p = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg($code))); $p->setInput($stream); $p->run(); From f3c2a9bedaad10633874b6bf89a95d0eb4a0c7fc Mon Sep 17 00:00:00 2001 From: Gladhon Date: Tue, 29 Dec 2015 09:29:43 +0100 Subject: [PATCH 10/10] [Form] fix Catchable Fatal Error if choices is not an array --- .../Form/Extension/Core/Type/ChoiceType.php | 30 +++++++++++-------- .../Extension/Core/Type/ChoiceTypeTest.php | 15 ++++++++++ 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 1465551b90..59c6303d0b 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -263,9 +263,11 @@ class ChoiceType extends AbstractType return $choices; } - ChoiceType::normalizeLegacyChoices($choices, $choiceLabels); + if (null === $choices) { + return; + } - return $choices; + return ChoiceType::normalizeLegacyChoices($choices, $choiceLabels); }; // BC closure, to be removed in 3.0 @@ -503,26 +505,30 @@ class ChoiceType extends AbstractType * are lost. Store them in a utility array that is used from the * "choice_label" closure by default. * - * @param array $choices The choice labels indexed by choices. - * Labels are replaced by generated keys. - * @param object $choiceLabels The object that receives the choice labels - * indexed by generated keys. - * @param int $nextKey The next generated key. + * @param array|\Traversable $choices The choice labels indexed by choices. + * @param object $choiceLabels The object that receives the choice labels + * indexed by generated keys. + * @param int $nextKey The next generated key. + * + * @return array The choices in a normalized array with labels replaced by generated keys. * * @internal Public only to be accessible from closures on PHP 5.3. Don't * use this method as it may be removed without notice and will be in 3.0. */ - public static function normalizeLegacyChoices(array &$choices, $choiceLabels, &$nextKey = 0) + public static function normalizeLegacyChoices($choices, $choiceLabels, &$nextKey = 0) { + $normalizedChoices = array(); + foreach ($choices as $choice => $choiceLabel) { - if (is_array($choiceLabel)) { - $choiceLabel = ''; // Dereference $choices[$choice] - self::normalizeLegacyChoices($choices[$choice], $choiceLabels, $nextKey); + if (is_array($choiceLabel) || $choiceLabel instanceof \Traversable) { + $normalizedChoices[$choice] = self::normalizeLegacyChoices($choiceLabel, $choiceLabels, $nextKey); continue; } $choiceLabels->labels[$nextKey] = $choiceLabel; - $choices[$choice] = $nextKey++; + $normalizedChoices[$choice] = $nextKey++; } + + return $normalizedChoices; } } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index b404405d19..d7536f7640 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -487,6 +487,21 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase $this->assertTrue($form->isSynchronized()); } + /** + * @group legacy + */ + public function testLegacyNullChoices() + { + $form = $this->factory->create('choice', null, array( + 'multiple' => false, + 'expanded' => false, + 'choices' => null, + )); + $this->assertNull($form->getConfig()->getOption('choices')); + $this->assertFalse($form->getConfig()->getOption('multiple')); + $this->assertFalse($form->getConfig()->getOption('expanded')); + } + /** * @group legacy */