Skip to content

Commit f89a436

Browse files
committed
Fix
1 parent 0afea8b commit f89a436

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

php_phongo.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,33 @@ static HashTable* php_phongo_std_get_gc(zend_object* object, zval** table, int*
162162
return object->handlers->get_properties(object);
163163
}
164164

165+
static zval* php_phongo_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv)
166+
{
167+
return zend_hash_find(object->handlers->get_properties(object), member);
168+
}
169+
170+
static zval *php_phongo_write_property(zend_object *zobj, zend_string *name, zval *value, void **cache_slot)
171+
{
172+
return zend_hash_add_new(zobj->handlers->get_properties(zobj), name, value);
173+
}
174+
static int php_phongo_has_property(zend_object *zobj, zend_string *name, int has_set_exists, void **cache_slot)
175+
{
176+
zval *value = zend_hash_find(zobj->handlers->get_properties(zobj), name);
177+
if (value) {
178+
if (has_set_exists == ZEND_PROPERTY_NOT_EMPTY) {
179+
return zend_is_true(value);
180+
}
181+
if (has_set_exists < ZEND_PROPERTY_NOT_EMPTY) {
182+
ZEND_ASSERT(has_set_exists == ZEND_PROPERTY_ISSET);
183+
ZVAL_DEREF(value);
184+
return (Z_TYPE_P(value) != IS_NULL);
185+
}
186+
ZEND_ASSERT(has_set_exists == ZEND_PROPERTY_EXISTS);
187+
return true;
188+
}
189+
return false;
190+
}
191+
165192
PHP_MINIT_FUNCTION(mongodb) /* {{{ */
166193
{
167194
bson_mem_vtable_t bson_mem_vtable = {
@@ -200,6 +227,9 @@ PHP_MINIT_FUNCTION(mongodb) /* {{{ */
200227
/* Ensure that get_gc delegates to zend_std_get_properties directly in case
201228
* our class defines a get_properties handler for debugging purposes. */
202229
phongo_std_object_handlers.get_gc = php_phongo_std_get_gc;
230+
phongo_std_object_handlers.read_property = php_phongo_read_property;
231+
phongo_std_object_handlers.write_property = php_phongo_write_property;
232+
phongo_std_object_handlers.has_property = php_phongo_has_property;
203233

204234
/* Initialize zend_class_entry dependencies.
205235
*

0 commit comments

Comments
 (0)