com php-src: Fixed bug #74269: Strict comparison of initial trait property values: NEWS UPGRADING Zend/tests/bug74269.phpt Zend/zend_inh eritance.c
| From: | Nikita Popov | Date: | Mon, 01 May 2017 10:59:27 +0000 |
| Subject: | com php-src: Fixed bug #74269: Strict comparison of initial trait property values: NEWS UPGRADING Zend/tests/bug74269.phpt Zend/zend_inh eritance.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-97741@lists.php.net to get a copy of this message | ||
Commit: 92124f9cdc20c6a9c22f9b54092ef945c41f2bb5
Author: Pedro Magalhães <mail@pmmaga.net> Mon, 10 Apr 2017 22:04:18 +0200
Committer: Nikita Popov <nikita.ppv@gmail.com> Mon, 1 May 2017 12:59:27 +0200
Parents: f9215b6519d4732498e598de9a3581297c60c4e8
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=92124f9cdc20c6a9c22f9b54092ef945c41f2bb5
Log:
Fixed bug #74269: Strict comparison of initial trait property values
Bugs:
https://bugs.php.net/74269
Changed paths:
M NEWS
M UPGRADING
A Zend/tests/bug74269.phpt
M Zend/zend_inheritance.c
Diff:
diff --git a/NEWS b/NEWS
index a699815..80aa4ec 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,8 @@ PHP NEWS
to interned strings handling in TS builds. (Anatol, Dmitry)
. Implemented "Trailing Commas In List Syntax" RFC for group use lists only.
(Sammy Kaye Powers)
+ . Fixed bug #74269 (It's possible to override trait property with different
+ loosely-equal value). (pmmaga)
- BCMath:
. Fixed bug #46564 (bcmod truncates fractionals). (liborm85)
diff --git a/UPGRADING b/UPGRADING
index e187766..78ce94c 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -39,6 +39,8 @@ PHP 7.2 UPGRADE NOTES
of a notice. They will generate an Error in a future version of PHP.
(https://wiki.php.net/rfc/deprecate-bareword-strings)
. Minimum supported Windows versions are Windows 7/Server 2008 R2.
+ . Initial trait property value compatibility check will no longer perform
+ any casts. (Bug #74269)
- BCMath:
. The bcmod() function no longer truncates fractional numbers to integers. As
diff --git a/Zend/tests/bug74269.phpt b/Zend/tests/bug74269.phpt
new file mode 100644
index 0000000..53ef570
--- /dev/null
+++ b/Zend/tests/bug74269..phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #74269: It's possible to override trait property with different loosely-equal value
+--FILE--
+<?php
+trait PropertiesTrait
+{
+ public $same = true;
+}
+
+class PropertiesExample
+{
+ use PropertiesTrait;
+ public $same = 2;
+}
+?>
+--EXPECTF--
+Fatal error: PropertiesExample and PropertiesTrait define the same property ($same) in the
composition of PropertiesExample. However, the definition differs and is considered incompatible.
Class was composed in %s
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 71b3eb0..675d8c4 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -23,7 +23,7 @@
#include "zend_execute.h"
#include "zend_inheritance.h"
#include "zend_smart_str.h"
-#include "zend_inheritance.h"
+#include "zend_operators.h"
static void overriden_ptr_dtor(zval *zv) /* {{{ */
{
@@ -1576,15 +1576,11 @@ static void zend_do_traits_property_binding(zend_class_entry *ce) /* {{{ */
== (flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC))) {
/* flags are identical, now the value needs to be checked */
if (flags & ZEND_ACC_STATIC) {
- not_compatible = (FAILURE == compare_function(&compare_result,
- &ce->default_static_members_table[coliding_prop->offset],
- &ce->traits[i]->default_static_members_table[property_info->offset]))
- || (Z_LVAL(compare_result) != 0);
+ not_compatible =
fast_is_not_identical_function(&ce->default_static_members_table[coliding_prop->offset],
+ &ce->traits[i]->default_static_members_table[property_info->offset]);
} else {
- not_compatible = (FAILURE == compare_function(&compare_result,
- &ce->default_properties_table[OBJ_PROP_TO_NUM(coliding_prop->offset)],
-
&ce->traits[i]->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]))
- || (Z_LVAL(compare_result) != 0);
+ not_compatible =
fast_is_not_identical_function(&ce->default_properties_table[OBJ_PROP_TO_NUM(coliding_prop->offset)],
+
&ce->traits[i]->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]);
}
} else {
/* the flags are not identical, thus, we assume properties are not compatible */