diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-01-10 12:28:32 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-01-10 12:37:24 +0100 |
commit | 32de3469d9eeebfaec8706865f10401656d60dba (patch) | |
tree | 339a229978e8b0d8e38d16dc65cdd3c0f96cfb40 /ext | |
parent | cf3317c790f968687f70ee5f738da1358ddf875b (diff) | |
download | php-git-32de3469d9eeebfaec8706865f10401656d60dba.tar.gz |
Manually initialize PDORow handlers
Makes it easier to see what is specified and what isn't, and allows
grepping...
Diffstat (limited to 'ext')
-rw-r--r-- | ext/pdo/pdo_stmt.c | 114 | ||||
-rw-r--r-- | ext/pdo/php_pdo_int.h | 2 |
2 files changed, 52 insertions, 64 deletions
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 37cca8a055..e938eaf4b4 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2262,38 +2262,7 @@ static zend_object *dbstmt_clone_obj(zval *zobject) } zend_object_handlers pdo_dbstmt_object_handlers; -static int pdo_row_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data); - -void pdo_stmt_init(void) -{ - zend_class_entry ce; - - INIT_CLASS_ENTRY(ce, "PDOStatement", pdo_dbstmt_functions); - pdo_dbstmt_ce = zend_register_internal_class(&ce); - pdo_dbstmt_ce->get_iterator = pdo_stmt_iter_get; - pdo_dbstmt_ce->create_object = pdo_dbstmt_new; - pdo_dbstmt_ce->serialize = zend_class_serialize_deny; - pdo_dbstmt_ce->unserialize = zend_class_unserialize_deny; - zend_class_implements(pdo_dbstmt_ce, 1, zend_ce_traversable); - zend_declare_property_null(pdo_dbstmt_ce, "queryString", sizeof("queryString")-1, ZEND_ACC_PUBLIC); - - memcpy(&pdo_dbstmt_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); - pdo_dbstmt_object_handlers.offset = XtOffsetOf(pdo_stmt_t, std); - pdo_dbstmt_object_handlers.dtor_obj = zend_objects_destroy_object; - pdo_dbstmt_object_handlers.free_obj = pdo_dbstmt_free_storage; - pdo_dbstmt_object_handlers.write_property = dbstmt_prop_write; - pdo_dbstmt_object_handlers.unset_property = dbstmt_prop_delete; - pdo_dbstmt_object_handlers.get_method = dbstmt_method_get; - pdo_dbstmt_object_handlers.compare_objects = dbstmt_compare; - pdo_dbstmt_object_handlers.clone_obj = dbstmt_clone_obj; - - INIT_CLASS_ENTRY(ce, "PDORow", pdo_row_functions); - pdo_row_ce = zend_register_internal_class(&ce); - pdo_row_ce->ce_flags |= ZEND_ACC_FINAL; /* when removing this a lot of handlers need to be redone */ - pdo_row_ce->create_object = pdo_row_new; - pdo_row_ce->serialize = pdo_row_serialize; - pdo_row_ce->unserialize = zend_class_unserialize_deny; -} +zend_object_handlers pdo_row_object_handlers; PDO_API void php_pdo_free_statement(pdo_stmt_t *stmt) { @@ -2656,37 +2625,6 @@ static int row_compare(zval *object1, zval *object2) return -1; } -const zend_object_handlers pdo_row_object_handlers = { - 0, - zend_objects_destroy_object, - pdo_row_free_storage, - NULL, - row_prop_read, - row_prop_write, - row_dim_read, - row_dim_write, - NULL, - NULL, - NULL, - row_prop_exists, - row_prop_delete, - row_dim_exists, - row_dim_delete, - row_get_properties, - row_method_get, - row_call_method, - row_get_ctor, - row_get_classname, - row_compare, - NULL, /* cast */ - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - void pdo_row_free_storage(zend_object *std) { 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 } /* }}} */ +void pdo_stmt_init(void) +{ + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, "PDOStatement", pdo_dbstmt_functions); + pdo_dbstmt_ce = zend_register_internal_class(&ce); + pdo_dbstmt_ce->get_iterator = pdo_stmt_iter_get; + pdo_dbstmt_ce->create_object = pdo_dbstmt_new; + pdo_dbstmt_ce->serialize = zend_class_serialize_deny; + pdo_dbstmt_ce->unserialize = zend_class_unserialize_deny; + zend_class_implements(pdo_dbstmt_ce, 1, zend_ce_traversable); + zend_declare_property_null(pdo_dbstmt_ce, "queryString", sizeof("queryString")-1, ZEND_ACC_PUBLIC); + + memcpy(&pdo_dbstmt_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); + pdo_dbstmt_object_handlers.offset = XtOffsetOf(pdo_stmt_t, std); + pdo_dbstmt_object_handlers.dtor_obj = zend_objects_destroy_object; + pdo_dbstmt_object_handlers.free_obj = pdo_dbstmt_free_storage; + pdo_dbstmt_object_handlers.write_property = dbstmt_prop_write; + pdo_dbstmt_object_handlers.unset_property = dbstmt_prop_delete; + pdo_dbstmt_object_handlers.get_method = dbstmt_method_get; + pdo_dbstmt_object_handlers.compare_objects = dbstmt_compare; + pdo_dbstmt_object_handlers.clone_obj = dbstmt_clone_obj; + + INIT_CLASS_ENTRY(ce, "PDORow", pdo_row_functions); + pdo_row_ce = zend_register_internal_class(&ce); + pdo_row_ce->ce_flags |= ZEND_ACC_FINAL; /* when removing this a lot of handlers need to be redone */ + pdo_row_ce->create_object = pdo_row_new; + pdo_row_ce->serialize = pdo_row_serialize; + pdo_row_ce->unserialize = zend_class_unserialize_deny; + + memcpy(&pdo_row_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); + pdo_row_object_handlers.free_obj = pdo_row_free_storage; + pdo_row_object_handlers.clone_obj = NULL; + pdo_row_object_handlers.get_property_ptr_ptr = NULL; + pdo_row_object_handlers.read_property = row_prop_read; + pdo_row_object_handlers.write_property = row_prop_write; + pdo_row_object_handlers.has_property = row_prop_exists; + pdo_row_object_handlers.unset_property = row_prop_delete; + pdo_row_object_handlers.read_dimension = row_dim_read; + pdo_row_object_handlers.write_dimension = row_dim_write; + pdo_row_object_handlers.has_dimension = row_dim_exists; + pdo_row_object_handlers.unset_dimension = row_dim_delete; + pdo_row_object_handlers.get_properties = row_get_properties; + pdo_row_object_handlers.get_method = row_method_get; + pdo_row_object_handlers.call_method = row_call_method; + pdo_row_object_handlers.get_constructor = row_get_ctor; + pdo_row_object_handlers.get_class_name = row_get_classname; + pdo_row_object_handlers.compare_objects = row_compare; +} + /* * Local variables: * tab-width: 4 diff --git a/ext/pdo/php_pdo_int.h b/ext/pdo/php_pdo_int.h index 17e3bd8a24..9a849c328e 100644 --- a/ext/pdo/php_pdo_int.h +++ b/ext/pdo/php_pdo_int.h @@ -49,7 +49,7 @@ extern zend_object *pdo_row_new(zend_class_entry *ce); extern const zend_function_entry pdo_row_functions[]; extern zend_class_entry *pdo_row_ce; void pdo_row_free_storage(zend_object *std); -extern const zend_object_handlers pdo_row_object_handlers; +extern zend_object_handlers pdo_row_object_handlers; zend_object_iterator *php_pdo_dbstmt_iter_get(zend_class_entry *ce, zval *object); |