From c0b9e9950a55e668fcd5a9d0d0977baadca59d99 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 31 May 2016 21:30:07 +0200 Subject: [PATCH 1/7] 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 265724627c..08796bd419 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 c1df9f210e53a9155343159a820e320a76d35582 Mon Sep 17 00:00:00 2001 From: Dword123 Date: Wed, 1 Jun 2016 13:20:21 +0200 Subject: [PATCH 2/7] 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 80c352a278..f3708ecffe 100644 --- a/src/Symfony/Component/Console/Output/StreamOutput.php +++ b/src/Symfony/Component/Console/Output/StreamOutput.php @@ -70,7 +70,7 @@ class StreamOutput extends Output */ 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 3/7] 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 7ed7b20e22..71c775edb8 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 e041da09e45960e941e39ae1ee744f287f85e251 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Thu, 2 Jun 2016 08:29:41 +0200 Subject: [PATCH 4/7] 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 a48fa8a353..1011535020 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 5/7] 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 e8795244b1..0c579d7724 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 f51ec8ed63..75e4a20e2a 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 1af321096e..9612320976 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 @@ class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase 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 @@ class PdoSessionHandlerTest extends \PHPUnit_Framework_TestCase 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 574f4e4147faeb59f0f4da659a80286edbb3fe62 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 3 Jun 2016 09:20:20 +0200 Subject: [PATCH 6/7] [appveyor] Ignore STATUS_HEAP_CORRUPTION errors on Windows --- phpunit | 10 ++++++++-- .../Tests/DataCollector/DumpDataCollectorTest.php | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/phpunit b/phpunit index 6d66f7b2b2..3ab3ca1686 100755 --- a/phpunit +++ b/phpunit @@ -53,6 +53,9 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__ chdir("phpunit-$PHPUNIT_VERSION"); passthru("$COMPOSER remove --no-update phpspec/prophecy"); passthru("$COMPOSER remove --no-update symfony/yaml"); + if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) { + passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\""); + } passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=3.1@dev\""); passthru("$COMPOSER install --prefer-dist --no-progress --ansi", $exit); if ($exit) { @@ -170,8 +173,11 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) { unlink($file); } - // Fail on any individual component failures but ignore STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409) and STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005) on Windows when APCu is enabled - if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !ini_get('apc.enable_cli') || (-1073740791 !== $procStatus && -1073741819 !== $procStatus))) { + // Fail on any individual component failures but ignore some error codes on Windows when APCu is enabled: + // STATUS_STACK_BUFFER_OVERRUN (-1073740791/0xC0000409) + // STATUS_ACCESS_VIOLATION (-1073741819/0xC0000005) + // STATUS_HEAP_CORRUPTION (-1073740940/0xC0000374) + if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !ini_get('apc.enable_cli') || !in_array($procStatus, array(-1073740791, -1073741819, -1073740940)))) { $exit = $procStatus; echo "\033[41mKO\033[0m $component\n\n"; } else { diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php index e9b8433c46..8675622891 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/DumpDataCollectorTest.php @@ -128,7 +128,7 @@ EOTXT; $line = __LINE__ - 1; ob_start(); - $collector = null; + $collector->__destruct(); if (PHP_VERSION_ID >= 50400) { $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n456\n", ob_get_clean()); } else { From 346149e7c81670b7c839155609680b220afb756b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 3 Jun 2016 10:10:46 +0200 Subject: [PATCH 7/7] [travis] Don't use parallel on HHVM --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1011535020..778d0e9c04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,6 +39,7 @@ cache: services: mongodb before_install: + - stty cols 120 - 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 @@ -76,8 +77,9 @@ install: script: - if [[ $skip ]]; then echo -e "\\n\\e[1;34mIntermediate PHP version $PHP is skipped for pull requests.\\e[0m"; fi - - 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 && ! $PHP = hhvm* ]]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi + - if [[ ! $deps && ! $PHP = hhvm* ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi + - if [[ ! $deps && $PHP = hhvm* ]]; then $PHPUNIT --exclude-group benchmark,intl-data; fi - if [[ ! $deps && $PHP = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\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 update --no-progress --ansi; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY; fi - if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi