Skip to content

Commit 32de346

Browse files
committed
Manually initialize PDORow handlers
Makes it easier to see what is specified and what isn't, and allows grepping...
1 parent cf3317c commit 32de346

File tree

2 files changed

+52
-64
lines changed

2 files changed

+52
-64
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 51 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2262,38 +2262,7 @@ static zend_object *dbstmt_clone_obj(zval *zobject)
22622262
}
22632263

22642264
zend_object_handlers pdo_dbstmt_object_handlers;
2265-
static int pdo_row_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data);
2266-
2267-
void pdo_stmt_init(void)
2268-
{
2269-
zend_class_entry ce;
2270-
2271-
INIT_CLASS_ENTRY(ce, "PDOStatement", pdo_dbstmt_functions);
2272-
pdo_dbstmt_ce = zend_register_internal_class(&ce);
2273-
pdo_dbstmt_ce->get_iterator = pdo_stmt_iter_get;
2274-
pdo_dbstmt_ce->create_object = pdo_dbstmt_new;
2275-
pdo_dbstmt_ce->serialize = zend_class_serialize_deny;
2276-
pdo_dbstmt_ce->unserialize = zend_class_unserialize_deny;
2277-
zend_class_implements(pdo_dbstmt_ce, 1, zend_ce_traversable);
2278-
zend_declare_property_null(pdo_dbstmt_ce, "queryString", sizeof("queryString")-1, ZEND_ACC_PUBLIC);
2279-
2280-
memcpy(&pdo_dbstmt_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
2281-
pdo_dbstmt_object_handlers.offset = XtOffsetOf(pdo_stmt_t, std);
2282-
pdo_dbstmt_object_handlers.dtor_obj = zend_objects_destroy_object;
2283-
pdo_dbstmt_object_handlers.free_obj = pdo_dbstmt_free_storage;
2284-
pdo_dbstmt_object_handlers.write_property = dbstmt_prop_write;
2285-
pdo_dbstmt_object_handlers.unset_property = dbstmt_prop_delete;
2286-
pdo_dbstmt_object_handlers.get_method = dbstmt_method_get;
2287-
pdo_dbstmt_object_handlers.compare_objects = dbstmt_compare;
2288-
pdo_dbstmt_object_handlers.clone_obj = dbstmt_clone_obj;
2289-
2290-
INIT_CLASS_ENTRY(ce, "PDORow", pdo_row_functions);
2291-
pdo_row_ce = zend_register_internal_class(&ce);
2292-
pdo_row_ce->ce_flags |= ZEND_ACC_FINAL; /* when removing this a lot of handlers need to be redone */
2293-
pdo_row_ce->create_object = pdo_row_new;
2294-
pdo_row_ce->serialize = pdo_row_serialize;
2295-
pdo_row_ce->unserialize = zend_class_unserialize_deny;
2296-
}
2265+
zend_object_handlers pdo_row_object_handlers;
22972266

22982267
PDO_API void php_pdo_free_statement(pdo_stmt_t *stmt)
22992268
{
@@ -2656,37 +2625,6 @@ static int row_compare(zval *object1, zval *object2)
26562625
return -1;
26572626
}
26582627

2659-
const zend_object_handlers pdo_row_object_handlers = {
2660-
0,
2661-
zend_objects_destroy_object,
2662-
pdo_row_free_storage,
2663-
NULL,
2664-
row_prop_read,
2665-
row_prop_write,
2666-
row_dim_read,
2667-
row_dim_write,
2668-
NULL,
2669-
NULL,
2670-
NULL,
2671-
row_prop_exists,
2672-
row_prop_delete,
2673-
row_dim_exists,
2674-
row_dim_delete,
2675-
row_get_properties,
2676-
row_method_get,
2677-
row_call_method,
2678-
row_get_ctor,
2679-
row_get_classname,
2680-
row_compare,
2681-
NULL, /* cast */
2682-
NULL,
2683-
NULL,
2684-
NULL,
2685-
NULL,
2686-
NULL,
2687-
NULL
2688-
};
2689-
26902628
void pdo_row_free_storage(zend_object *std)
26912629
{
26922630
pdo_row_t *row = (pdo_row_t *)std;
@@ -2712,6 +2650,56 @@ static int pdo_row_serialize(zval *object, unsigned char **buffer, size_t *buf_l
27122650
}
27132651
/* }}} */
27142652

2653+
void pdo_stmt_init(void)
2654+
{
2655+
zend_class_entry ce;
2656+
2657+
INIT_CLASS_ENTRY(ce, "PDOStatement", pdo_dbstmt_functions);
2658+
pdo_dbstmt_ce = zend_register_internal_class(&ce);
2659+
pdo_dbstmt_ce->get_iterator = pdo_stmt_iter_get;
2660+
pdo_dbstmt_ce->create_object = pdo_dbstmt_new;
2661+
pdo_dbstmt_ce->serialize = zend_class_serialize_deny;
2662+
pdo_dbstmt_ce->unserialize = zend_class_unserialize_deny;
2663+
zend_class_implements(pdo_dbstmt_ce, 1, zend_ce_traversable);
2664+
zend_declare_property_null(pdo_dbstmt_ce, "queryString", sizeof("queryString")-1, ZEND_ACC_PUBLIC);
2665+
2666+
memcpy(&pdo_dbstmt_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
2667+
pdo_dbstmt_object_handlers.offset = XtOffsetOf(pdo_stmt_t, std);
2668+
pdo_dbstmt_object_handlers.dtor_obj = zend_objects_destroy_object;
2669+
pdo_dbstmt_object_handlers.free_obj = pdo_dbstmt_free_storage;
2670+
pdo_dbstmt_object_handlers.write_property = dbstmt_prop_write;
2671+
pdo_dbstmt_object_handlers.unset_property = dbstmt_prop_delete;
2672+
pdo_dbstmt_object_handlers.get_method = dbstmt_method_get;
2673+
pdo_dbstmt_object_handlers.compare_objects = dbstmt_compare;
2674+
pdo_dbstmt_object_handlers.clone_obj = dbstmt_clone_obj;
2675+
2676+
INIT_CLASS_ENTRY(ce, "PDORow", pdo_row_functions);
2677+
pdo_row_ce = zend_register_internal_class(&ce);
2678+
pdo_row_ce->ce_flags |= ZEND_ACC_FINAL; /* when removing this a lot of handlers need to be redone */
2679+
pdo_row_ce->create_object = pdo_row_new;
2680+
pdo_row_ce->serialize = pdo_row_serialize;
2681+
pdo_row_ce->unserialize = zend_class_unserialize_deny;
2682+
2683+
memcpy(&pdo_row_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
2684+
pdo_row_object_handlers.free_obj = pdo_row_free_storage;
2685+
pdo_row_object_handlers.clone_obj = NULL;
2686+
pdo_row_object_handlers.get_property_ptr_ptr = NULL;
2687+
pdo_row_object_handlers.read_property = row_prop_read;
2688+
pdo_row_object_handlers.write_property = row_prop_write;
2689+
pdo_row_object_handlers.has_property = row_prop_exists;
2690+
pdo_row_object_handlers.unset_property = row_prop_delete;
2691+
pdo_row_object_handlers.read_dimension = row_dim_read;
2692+
pdo_row_object_handlers.write_dimension = row_dim_write;
2693+
pdo_row_object_handlers.has_dimension = row_dim_exists;
2694+
pdo_row_object_handlers.unset_dimension = row_dim_delete;
2695+
pdo_row_object_handlers.get_properties = row_get_properties;
2696+
pdo_row_object_handlers.get_method = row_method_get;
2697+
pdo_row_object_handlers.call_method = row_call_method;
2698+
pdo_row_object_handlers.get_constructor = row_get_ctor;
2699+
pdo_row_object_handlers.get_class_name = row_get_classname;
2700+
pdo_row_object_handlers.compare_objects = row_compare;
2701+
}
2702+
27152703
/*
27162704
* Local variables:
27172705
* tab-width: 4

ext/pdo/php_pdo_int.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ extern zend_object *pdo_row_new(zend_class_entry *ce);
4949
extern const zend_function_entry pdo_row_functions[];
5050
extern zend_class_entry *pdo_row_ce;
5151
void pdo_row_free_storage(zend_object *std);
52-
extern const zend_object_handlers pdo_row_object_handlers;
52+
extern zend_object_handlers pdo_row_object_handlers;
5353

5454
zend_object_iterator *php_pdo_dbstmt_iter_get(zend_class_entry *ce, zval *object);
5555

0 commit comments

Comments
 (0)