From 3dce1d40d5f9fab1795be4a2b82759b2c8cf810a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 May 2016 09:24:18 +0200 Subject: [PATCH 01/19] updated CHANGELOG for 3.1.0 --- CHANGELOG-3.1.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG-3.1.md b/CHANGELOG-3.1.md index cb59a7e2ec..eb6cb03840 100644 --- a/CHANGELOG-3.1.md +++ b/CHANGELOG-3.1.md @@ -7,6 +7,12 @@ in 3.1 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/v3.1.0...v3.1.1 +* 3.1.0 (2016-05-30) + + * bug #18889 [Console] SymfonyStyle: Fix alignment/prefixing of multi-line comments (chalasr) + * bug #18907 [Routing] Fix the annotation loader taking a class constant as a beginning of a class name (jakzal, nicolas-grekas) + * bug #18899 [Yaml] search for colons in strings only (xabbuh) + * 3.1.0-RC1 (2016-05-26) * bug #18879 [Console] SymfonyStyle: Align multi-line/very-long-line blocks (chalasr) From e62f832521e9671f36ec6fc1ab8d348176bc3a51 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 May 2016 09:24:26 +0200 Subject: [PATCH 02/19] updated VERSION for 3.1.0 --- 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 e891863321..c26ee93180 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-DEV'; + const VERSION = '3.1.0'; const VERSION_ID = 30100; const MAJOR_VERSION = 3; const MINOR_VERSION = 1; const RELEASE_VERSION = 0; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '01/2017'; const END_OF_LIFE = '07/2017'; From 76e30a988193a3b51b8580d440531a54b02dd3fa Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 30 May 2016 09:57:32 +0200 Subject: [PATCH 03/19] 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 c26ee93180..9657138b6a 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 240cf0aaa8d8bbb0180ed1c762709741cb1a65b9 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 30 May 2016 10:20:49 +0200 Subject: [PATCH 04/19] [#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 5d91a9fd1e..8a09e516cd 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php @@ -545,6 +545,28 @@ class ObjectNormalizerTest extends \PHPUnit_Framework_TestCase $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 d14f0bf71f787c60ce742325531e82e02e024485 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 31 May 2016 21:27:35 +0200 Subject: [PATCH 05/19] 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 8c509b36f0..2dd04e8b64 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 06/19] 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 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 07/19] [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 09e8948ded..6c20c83af1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConsoleCommandPass.php @@ -38,7 +38,7 @@ class AddConsoleCommandPass implements CompilerPassInterface 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 72902c99cd..d488405544 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 @@ class AddConsoleCommandPassTest extends \PHPUnit_Framework_TestCase $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 08/19] 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 09/19] 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 58996ac0bf6fe14251a9842c6a66d8ff4c3c29bb Mon Sep 17 00:00:00 2001 From: Charles Sarrazin Date: Wed, 1 Jun 2016 21:35:13 +0200 Subject: [PATCH 10/19] 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 d19ae1eab8..9306169010 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 11/19] 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 e722c98e6d..5eb7668dac 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 12/19] 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 13/19] 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 ff2d189f348e72f25c3169a67a826acc1944cca2 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Thu, 2 Jun 2016 13:03:22 +0200 Subject: [PATCH 14/19] [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 7c0cfc9340..540d998206 100644 --- a/src/Symfony/Component/Security/Core/Authorization/DebugAccessDecisionManager.php +++ b/src/Symfony/Component/Security/Core/Authorization/DebugAccessDecisionManager.php @@ -103,7 +103,14 @@ class DebugAccessDecisionManager implements AccessDecisionManagerInterface } 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 0000000000..f90f7769ba --- /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 15/19] 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 18f20834f0..136e9db9e7 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 7193158b2b..3207b3c95a 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 -%}