From dfc335fd4e9dddcafe43cb814e4910310fa337b2 Mon Sep 17 00:00:00 2001 From: Tugdual Saunier Date: Tue, 23 Jul 2013 21:45:47 +0200 Subject: [PATCH 1/2] Added test case for issue #1143 --- .../Tests/Fixtures/regression/issue_1143.test | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/Twig/Tests/Fixtures/regression/issue_1143.test diff --git a/test/Twig/Tests/Fixtures/regression/issue_1143.test b/test/Twig/Tests/Fixtures/regression/issue_1143.test new file mode 100644 index 000000000..ff7c8bb70 --- /dev/null +++ b/test/Twig/Tests/Fixtures/regression/issue_1143.test @@ -0,0 +1,23 @@ +--TEST-- +error in twig extension +--TEMPLATE-- +{{ object.region is not null ? object.regionChoices[object.region] }} +--DATA-- +class House +{ + const REGION_S = 1; + const REGION_P = 2; + + public static $regionChoices = array(self::REGION_S => 'house.region.s', self::REGION_P => 'house.region.p'); + + public function getRegionChoices() + { + return self::$regionChoices; + } +} + +$object = new House(); +$object->region = 1; +return array('object' => $object) +--EXPECT-- +house.region.s From 5042159ec4d182333da0fa6ef7063b70ecaafed1 Mon Sep 17 00:00:00 2001 From: Tugdual Saunier Date: Sun, 4 Aug 2013 12:10:59 +0200 Subject: [PATCH 2/2] [ext] access static properties, fixed #1143 Twig extension access static properties wheras it should not --- ext/twig/twig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/twig/twig.c b/ext/twig/twig.c index 0e5a0efb4..26b1fe6eb 100644 --- a/ext/twig/twig.c +++ b/ext/twig/twig.c @@ -698,7 +698,7 @@ static int twig_add_property_to_class(void *pDest APPLY_TSRMLS_DC, int num_args, zend_property_info *pptr = (zend_property_info *) pDest; APPLY_TSRMLS_FETCH(); - if (!(pptr->flags & ZEND_ACC_PUBLIC)) { + if (!(pptr->flags & ZEND_ACC_PUBLIC) || (pptr->flags & ZEND_ACC_STATIC)) { return 0; }