]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.3' into PHP-7.4
authorJoe Watkins <krakjoe@php.net>
Fri, 5 Apr 2019 23:30:03 +0000 (01:30 +0200)
committerJoe Watkins <krakjoe@php.net>
Fri, 5 Apr 2019 23:31:32 +0000 (01:31 +0200)
* PHP-7.3:
  Follow up #77849 PDOStatement objects in undefined state after clone

1  2 
ext/pdo/pdo_stmt.c

index c3e79f5b68d3a8d0576b0ff6fa78a915ba1fc019,873f977fb6fc6b6f38e3b127dc81dcf9e4f35681..6e0f22cd6e683e4883d7f51335fdd0e90057c2fa
@@@ -2246,24 -2263,37 +2246,8 @@@ static int dbstmt_compare(zval *object1
        return -1;
  }
  
- static zend_object *dbstmt_clone_obj(zval *zobject)
- {
-       pdo_stmt_t *stmt;
-       pdo_stmt_t *old_stmt;
-       stmt = zend_object_alloc(sizeof(pdo_stmt_t), Z_OBJCE_P(zobject));
-       zend_object_std_init(&stmt->std, Z_OBJCE_P(zobject));
-       object_properties_init(&stmt->std, Z_OBJCE_P(zobject));
-       old_stmt = Z_PDO_STMT_P(zobject);
-       zend_objects_clone_members(&stmt->std, &old_stmt->std);
-       return &stmt->std;
- }
  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;
 -      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 = NULL;
 -
 -      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)
  {
@@@ -2646,52 -2705,18 +2630,52 @@@ zend_object *pdo_row_new(zend_class_ent
        return &row->std;
  }
  
 -static int pdo_row_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data)
 +void pdo_stmt_init(void)
  {
 -      php_error_docref(NULL, E_WARNING, "PDORow instances may not be serialized");
 -      return FAILURE;
 -}
 -/* }}} */
 +      zend_class_entry ce;
  
 -/*
 - * Local variables:
 - * tab-width: 4
 - * c-basic-offset: 4
 - * End:
 - * vim600: noet sw=4 ts=4 fdm=marker
 - * vim<600: noet sw=4 ts=4
 - */
 +      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;
++      pdo_dbstmt_object_handlers.clone_obj = NULL;
 +
 +      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 = zend_class_serialize_deny;
 +      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_for = row_get_properties_for;
 +      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;
 +}