From 1dcca1a8df40258168e22a58077873a87b3b623a Mon Sep 17 00:00:00 2001 From: Nicolas Macherey Date: Thu, 9 Jul 2015 13:44:18 +0200 Subject: [PATCH 1/5] =?UTF-8?q?[PropertyAccess]=C2=A0setValue=20&=20isWrit?= =?UTF-8?q?able=20loops=20must=20only=20stops=20on=20reference=20and=20obj?= =?UTF-8?q?ect.=20References=20can=20also=20be=20arrays=20and=20if=20the?= =?UTF-8?q?=20loop=20stops=20the=20value=20is=20never=20set=20in=20the=20o?= =?UTF-8?q?bject.=20(Breaks=20since=202.6.5=20commit=20e3e4695)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This merge request fixes the following cases taht was working with version previous to 2.6.5: A class with a property myArray which can be a multi dimensional array can now be accesed using myArray[foo][bar][baz] Previously only myArray[foo] was working. The break is since commit e3e4695 This commit adds additionnal testing, and is rebased from 2.6 upstream --- .../PropertyAccess/PropertyAccessor.php | 4 +- .../Tests/Fixtures/TestClassIsWritable.php | 27 +++++++++++ .../Tests/Fixtures/TestClassSetValue.php | 32 +++++++++++++ .../Tests/PropertyAccessorTest.php | 45 ++++++++++++++++++- 4 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassIsWritable.php create mode 100644 src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassSetValue.php diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index f13a5c9175..182d9fc024 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -88,7 +88,7 @@ class PropertyAccessor implements PropertyAccessorInterface $this->writeProperty($objectOrArray, $property, $value); } - if ($propertyValues[$i][self::IS_REF]) { + if ($propertyValues[$i][self::IS_REF] && is_object($objectOrArray)) { return; } @@ -149,7 +149,7 @@ class PropertyAccessor implements PropertyAccessorInterface } } - if ($propertyValues[$i][self::IS_REF]) { + if ($propertyValues[$i][self::IS_REF] && is_object($objectOrArray)) { return true; } } diff --git a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassIsWritable.php b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassIsWritable.php new file mode 100644 index 0000000000..d07c7c0fa8 --- /dev/null +++ b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassIsWritable.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\PropertyAccess\Tests\Fixtures; + +class TestClassIsWritable +{ + protected $value; + + public function getValue() + { + return $this->value; + } + + public function __construct($value) + { + $this->value = $value; + } +} \ No newline at end of file diff --git a/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassSetValue.php b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassSetValue.php new file mode 100644 index 0000000000..638afee6af --- /dev/null +++ b/src/Symfony/Component/PropertyAccess/Tests/Fixtures/TestClassSetValue.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\PropertyAccess\Tests\Fixtures; + +class TestClassSetValue +{ + protected $value; + + public function getValue() + { + return $this->value; + } + + public function setValue($value) + { + $this->value = $value; + } + + public function __construct($value) + { + $this->value = $value; + } +} \ No newline at end of file diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index 9a5324f781..aedca2e822 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -16,6 +16,8 @@ use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClass; use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassMagicCall; use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassMagicGet; use Symfony\Component\PropertyAccess\Tests\Fixtures\Ticket5775Object; +use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassSetValue; +use Symfony\Component\PropertyAccess\Tests\Fixtures\TestClassIsWritable; class PropertyAccessorTest extends \PHPUnit_Framework_TestCase { @@ -446,4 +448,45 @@ class PropertyAccessorTest extends \PHPUnit_Framework_TestCase $this->propertyAccessor->setValue($obj, 'publicProperty[foo][bar]', 'Updated'); $this->assertSame('Updated', $obj->publicProperty['foo']['bar']); } -} + + public function getReferenceChainObjectsForSetValue() + { + return array( + array(array('a' => array('b' => array('c' => 'old-value'))), '[a][b][c]', 'new-value'), + array(new TestClassSetValue(new TestClassSetValue('old-value')), 'value.value', 'new-value'), + array(new TestClassSetValue(array('a' => array('b' => array('c' => new TestClassSetValue('old-value'))))), 'value[a][b][c].value', 'new-value'), + array(new TestClassSetValue(array('a' => array('b' => 'old-value'))), 'value[a][b]', 'new-value'), + array(new \ArrayIterator(array('a' => array('b' => array('c' => 'old-value')))), '[a][b][c]', 'new-value'), + ); + + } + + /** + * @dataProvider getReferenceChainObjectsForSetValue + */ + public function testSetValueForReferenceChainIssue($object, $path, $value) + { + $this->propertyAccessor->setValue($object, $path, $value); + + $this->assertEquals($value, $this->propertyAccessor->getValue($object, $path)); + } + + public function getReferenceChainObjectsForIsWritable() + { + return array( + array(new TestClassIsWritable(array('a' => array('b' => 'old-value'))), 'value[a][b]', false), + array(new TestClassIsWritable(new \ArrayIterator(array('a' => array('b' => 'old-value')))), 'value[a][b]', true), + array(new TestClassIsWritable(array('a' => array('b' => array('c' => new TestClassSetValue('old-value'))))), 'value[a][b][c].value', true), + ); + + } + + /** + * @dataProvider getReferenceChainObjectsForIsWritable + */ + public function testIsWritableForReferenceChainIssue($object, $path, $value) + { + $this->assertEquals($value, $this->propertyAccessor->isWritable($object, $path)); + } + +} \ No newline at end of file From 524ccac97c9e3b180461cac46a9e14e27a60897d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 13 Jul 2015 11:34:21 +0200 Subject: [PATCH 2/5] updated CHANGELOG for 2.6.10 --- CHANGELOG-2.6.md | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/CHANGELOG-2.6.md b/CHANGELOG-2.6.md index 8d179c384c..e466668f8f 100644 --- a/CHANGELOG-2.6.md +++ b/CHANGELOG-2.6.md @@ -7,6 +7,55 @@ in 2.6 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.6.0...v2.6.1 +* 2.6.10 (2015-07-13) + + * bug #15248 Added 'default' color (jaytaph) + * bug #15243 Reload the session after regenerating its id (jakzal) + * bug #15202 [Security] allow to use `method` in XML configs (xabbuh) + * bug #15218 [Twig][Bridge] replaced `extends` with `use` in bootstrap_3_horizontal_layout.html.twig (MatTheCat) + * bug #15223 [Finder] Command::addAtIndex() fails with Command instance argument (thunderer) + * bug #15220 [DependencyInjection] Freeze also FrozenParameterBag::remove (lyrixx) + * bug #15110 Add a way to reset the singleton (dawehner) + * bug #15115 [Validator] always evaluate binary format when changed (xabbuh) + * bug #15163 Update DateTimeToArrayTransformer.php (zhil) + * bug #15150 [Translation] Azerbaijani language pluralization rule is wrong (shehi) + * bug #15159 Towards 100% HHVM compat (nicolas-grekas) + * bug #15146 Towards 100% HHVM compat (nicolas-grekas) + * bug #15069 [Form] Fixed: Data mappers always receive forms indexed by their names (webmozart) + * bug #15137 [Security] Initialize SwitchUserEvent::targetUser on attemptExitUser (Rvanlaak, xabbuh) + * bug #15126 [Validator] Fix BC for Validator's validate method (michalmarcinkowski) + * bug #15083 [DependencyInjection] Fail when dumping a Definition with no class nor factory (nicolas-grekas) + * bug #15127 [Validator] fix validation for Maestro UK card numbers (xabbuh) + * bug #15128 DbalLogger: Small nonutf8 array fix (vpetrovych, weaverryan) + * bug #15048 [Translation][Form][choice] empty_value shouldn't be translated when it has an empty value (Restless-ET) + * bug #15117 [Form] fixed sending non array data on submit to ResizeListener (BruceWouaigne) + * bug #15102 [Translation][debug cmd] fixed failing tests. (aitboudad) + * bug #13750 [DependencyInjection] Fixed decoration of service for service with parent (hason) + * bug #15086 Fixed the regexp for the validator of Maestro-based credit/debit cards (javiereguiluz) + * bug #15058 [Console] Fix STDERR output text on IBM iSeries OS400 (johnkary) + * bug #14853 [Validator] more strict e-mail validation regex (xabbuh) + * bug #15065 [Form] Fixed: remove quoted strings from Intl date formats (e.g. es_ES full pattern) (webmozart) + * bug #15039 [Translation][update cmd] taken account into bundle overrides path. (aitboudad) + * bug #15038 [Translation][debug cmd] taken account into bundle overrides path. (aitboudad) + * bug #14964 [bugfix][MonologBridge] WebProcessor: passing $extraFields to BaseWebProcessor (MacDada) + * bug #15036 [VarDumper] Fix dump output for better readability (nicolas-grekas) + * bug #15027 [Form] Fixed: Filter non-integers when selecting entities by int ID (webmozart, nicolas-grekas) + * bug #15000 [Debug] Fix fatal-errors handling on HHVM (nicolas-grekas) + * bug #14999 [Debug] Fix fatal-errors handling on HHVM (nicolas-grekas, digitalkaoz) + * bug #14959 [Debug+VarDumper] Fix handling of PHP7 "Throwable" exceptions (nicolas-grekas) + * bug #15010 [Debug] Fix log level of stacked errors (nicolas-grekas) + * bug #15017 [VarDumper] Fix uninitialized id in HtmlDumper (nicolas-grekas) + * bug #14980 Fixed fluent interface (jaytaph) + * bug #14974 [Security][Translation] #14920 update translations (vincentaubert) + * bug #14930 Bug #14836 [HttpFoundation] Moves default JSON encoding assignment fr… (Incognito) + * bug #14897 Allow new lines in Messages translated with transchoice() (replacement for #14867) (azine) + * bug #14895 [Form] Support DateTimeImmutable in transform() (c960657) + * bug #14891 without this change allways the legacy code get called (dominikzogg) + * bug #14859 Improve the config validation in TwigBundle (stof) + * bug #14785 [BrowserKit] Fix bug when uri starts with http. (amouhzi) + * bug #14807 [Security][Acl] enforce string identifiers (xabbuh) + * bug #14808 [WebProfilerBundle][logger] added missing deprecation message. (aitboudad) + * 2.6.9 (2015-05-30) * bug #14777 Avoid using the app global variable in the profiler templates (stof) From e246af5f3bdf64fa5a85936ee78e3574e094cf5f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 13 Jul 2015 11:34:32 +0200 Subject: [PATCH 3/5] updated VERSION for 2.6.10 --- 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 3efc7d52ea..99dd895a96 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -60,12 +60,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.6.10-DEV'; + const VERSION = '2.6.10'; const VERSION_ID = '20610'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '6'; const RELEASE_VERSION = '10'; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; /** * Constructor. From 1e668dd8058b12c4fb787907eb0ca5518ad304d8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 13 Jul 2015 11:49:29 +0200 Subject: [PATCH 4/5] bumped Symfony version to 2.6.11 --- 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 99dd895a96..7bae3bc5ce 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -60,12 +60,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface protected $startTime; protected $loadClassCache; - const VERSION = '2.6.10'; - const VERSION_ID = '20610'; + const VERSION = '2.6.11-DEV'; + const VERSION_ID = '20611'; const MAJOR_VERSION = '2'; const MINOR_VERSION = '6'; - const RELEASE_VERSION = '10'; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = '11'; + const EXTRA_VERSION = 'DEV'; /** * Constructor. From 1adb065d7017f07d6b79d345b7bd33448d426959 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 16 Jul 2015 10:43:55 +0200 Subject: [PATCH 5/5] [HttpFoundation] Fix Response::closeOutputBuffers() for HHVM 3.3 --- src/Symfony/Component/HttpFoundation/Response.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index dc7203a8d1..17fb98102b 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -1242,7 +1242,7 @@ class Response { $status = ob_get_status(true); $level = count($status); - $flags = PHP_VERSION_ID >= 50400 ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1; + $flags = defined('PHP_OUTPUT_HANDLER_REMOVABLE') ? PHP_OUTPUT_HANDLER_REMOVABLE | ($flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE) : -1; while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || $flags === ($s['flags'] & $flags) : $s['del'])) { if ($flush) {