Skip to content

Commit 2d0d49f

Browse files
committed
Deal with ZEND_ACC_VIRTUAL properties consistently
1 parent c70f217 commit 2d0d49f

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

Diff for: src/handlers.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ zval* pmmpthread_read_property(PMMPTHREAD_READ_PROPERTY_PASSTHRU_D) {
9393
zend_property_info* info = zend_get_property_info(object->ce, member, 0);
9494
if (info == ZEND_WRONG_PROPERTY_INFO) {
9595
rv = &EG(uninitialized_zval);
96-
} else if (info == NULL || (info->flags & ZEND_ACC_STATIC) != 0) { //dynamic property
96+
} else if (info == NULL || !PMMPTHREAD_OBJECT_PROPERTY(info)) { //dynamic property
9797
if (pmmpthread_store_read(object, &zmember, type, rv) == FAILURE) {
9898
if (type != BP_VAR_IS) {
9999
zend_error(E_WARNING, "Undefined property: %s::$%s", ZSTR_VAL(object->ce->name), ZSTR_VAL(member));
@@ -161,7 +161,7 @@ zval* pmmpthread_write_property(PMMPTHREAD_WRITE_PROPERTY_PASSTHRU_D) {
161161
bool ok = true;
162162
zend_property_info* info = zend_get_property_info(object->ce, member, 0);
163163
if (info != ZEND_WRONG_PROPERTY_INFO) {
164-
if (info != NULL && (info->flags & ZEND_ACC_STATIC) == 0) {
164+
if (info != NULL && PMMPTHREAD_OBJECT_PROPERTY(info)) {
165165
ZVAL_STR(&zmember, info->name); //use mangled name to avoid private member shadowing issues
166166

167167
zend_execute_data* execute_data = EG(current_execute_data);
@@ -232,7 +232,7 @@ int pmmpthread_has_property(PMMPTHREAD_HAS_PROPERTY_PASSTHRU_D) {
232232
} else {
233233
zend_property_info* info = zend_get_property_info(object->ce, member, 1);
234234
if (info != ZEND_WRONG_PROPERTY_INFO) {
235-
if (info != NULL && (info->flags & ZEND_ACC_STATIC) == 0) {
235+
if (info != NULL && PMMPTHREAD_OBJECT_PROPERTY(info)) {
236236
ZVAL_STR(&zmember, info->name); //defined property, use mangled name
237237
}
238238
isset = pmmpthread_store_isset(object, &zmember, has_set_exists);
@@ -272,7 +272,7 @@ void pmmpthread_unset_property(PMMPTHREAD_UNSET_PROPERTY_PASSTHRU_D) {
272272
} else {
273273
zend_property_info* info = zend_get_property_info(object->ce, member, 0);
274274
if (info != ZEND_WRONG_PROPERTY_INFO) {
275-
if (info != NULL && (info->flags & ZEND_ACC_STATIC) == 0) {
275+
if (info != NULL && PMMPTHREAD_OBJECT_PROPERTY(info)) {
276276
ZVAL_STR(&zmember, info->name); //defined property, use mangled name
277277
}
278278
pmmpthread_store_delete(object, &zmember);

Diff for: src/object.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static inline void pmmpthread_base_write_property_defaults(pmmpthread_zend_objec
248248
zval* value;
249249
int result;
250250

251-
if (info->flags & ZEND_ACC_STATIC) {
251+
if (!PMMPTHREAD_OBJECT_PROPERTY(info)) {
252252
continue;
253253
}
254254

Diff for: src/pmmpthread.h

+6
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ typedef struct _pmmpthread_call_t {
163163

164164
#define PMMPTHREAD_CALL_EMPTY {empty_fcall_info, empty_fcall_info_cache}
165165

166+
#if PHP_VERSION_ID >= 80400
167+
#define PMMPTHREAD_OBJECT_PROPERTY(prop_info) ((prop_info->flags & (ZEND_ACC_STATIC | ZEND_ACC_VIRTUAL)) == 0)
168+
#else
169+
#define PMMPTHREAD_OBJECT_PROPERTY(prop_info) ((prop_info->flags & ZEND_ACC_STATIC) == 0)
170+
#endif
171+
166172
/* this is a copy of the same struct in zend_closures.c, which unfortunately isn't exported */
167173
typedef struct _zend_closure {
168174
zend_object std;

Diff for: src/prepare.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,7 @@ static void prepare_class_property_table(const pmmpthread_ident_t* source, zend_
302302
}
303303

304304
ZEND_HASH_FOREACH_PTR(&prepared->properties_info, info) {
305-
if (info->ce == prepared && (info->flags & ZEND_ACC_STATIC) == 0
306-
#if PHP_VERSION_ID >= 80400
307-
&& (info->flags & ZEND_ACC_VIRTUAL) == 0
308-
#endif
309-
) {
305+
if (info->ce == prepared && PMMPTHREAD_OBJECT_PROPERTY(info)) {
310306
prepared->properties_info_table[OBJ_PROP_TO_NUM(info->offset)] = info;
311307
}
312308
} ZEND_HASH_FOREACH_END();

Diff for: src/store.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ void pmmpthread_store_tohash(zend_object *object, HashTable *hash) {
835835

836836
for (int i = 0; i < object->ce->default_properties_count; i++) {
837837
zend_property_info* info = object->ce->properties_info_table[i];
838-
if (info == NULL || (info->flags & ZEND_ACC_STATIC) != 0) {
838+
if (info == NULL || !PMMPTHREAD_OBJECT_PROPERTY(info)) {
839839
continue;
840840
}
841841

0 commit comments

Comments
 (0)