Skip to content

Instantly share code, notes, and snippets.

@m6w6
Created August 17, 2015 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m6w6/d51e7ef822cb8082c0ed to your computer and use it in GitHub Desktop.
Save m6w6/d51e7ef822cb8082c0ed to your computer and use it in GitHub Desktop.
Fix inheritance of internal interafce's constants
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 77ea7d5..3ccade9 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -917,7 +917,13 @@ static zend_bool do_inherit_constant_check(HashTable *child_constants_table, zva
static void do_inherit_iface_constant(zend_string *name, zval *zv, zend_class_entry *ce, zend_class_entry *iface) /* {{{ */
{
if (do_inherit_constant_check(&ce->constants_table, zv, name, iface)) {
- ZVAL_MAKE_REF(zv);
+ if (!Z_ISREF_P(zv)) {
+ if (iface->type == ZEND_INTERNAL_CLASS) {
+ ZVAL_NEW_PERSISTENT_REF(zv, zv);
+ } else {
+ ZVAL_NEW_REF(zv, zv);
+ }
+ }
Z_ADDREF_P(zv);
if (Z_CONSTANT_P(Z_REFVAL_P(zv))) {
ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment