Skip to content

Commit 86a9318

Browse files
fixed issue for php 7.4 and higher when interfaces inherited other interfaces (php 7.4 turned the "interface_gets_implemented" and "create_object" methods of the zend_class_entry struct into a union, which caused an issue when the create_object property was set for interfaces)
1 parent f5e38d7 commit 86a9318

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

zend/classimpl.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,8 +1366,10 @@ zend_class_entry *ClassImpl::initialize(ClassBase *base, const std::string &pref
13661366
// initialize the class entry
13671367
INIT_CLASS_ENTRY_EX(entry, _name.c_str(), _name.size(), entries());
13681368

1369-
// we need a special constructor
1370-
entry.create_object = &ClassImpl::createObject;
1369+
// we need a special constructor, but only for real classes, not for interfaces.
1370+
// (in fact: from php 7.4 onwards the create_object method is part of union
1371+
// together with the interface_gets_implemented method, which causes a crash)
1372+
if (_type != ClassType::Interface) entry.create_object = &ClassImpl::createObject;
13711373

13721374
// register function that is called for static method calls
13731375
entry.get_static_method = &ClassImpl::getStaticMethod;
@@ -1419,7 +1421,7 @@ zend_class_entry *ClassImpl::initialize(ClassBase *base, const std::string &pref
14191421
_entry = zend_register_internal_class(&entry);
14201422
}
14211423

1422-
// register the classes
1424+
// register the interfaces
14231425
for (auto &interface : _interfaces)
14241426
{
14251427
// register this interface

0 commit comments

Comments
 (0)