]> granicus.if.org Git - php/commitdiff
Manually initialize PDORow handlers
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 10 Jan 2019 11:28:32 +0000 (12:28 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 10 Jan 2019 11:37:24 +0000 (12:37 +0100)
Makes it easier to see what is specified and what isn't, and allows
grepping...

ext/pdo/pdo_stmt.c
ext/pdo/php_pdo_int.h

index 37cca8a05555dc6cd22e19e933dc344522c44446..e938eaf4b4afe4943ca6c3a068bc0331362b7866 100644 (file)
@@ -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
index 17e3bd8a24d90cbf754463f4bc072721d84c2354..9a849c328e4918c9005dd391b0d2b697d541520b 100644 (file)
@@ -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);