]> granicus.if.org Git - php/commitdiff
Fixed PDO objects binary incompatibility
authorDmitry Stogov <dmitry@php.net>
Thu, 6 May 2010 08:37:41 +0000 (08:37 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 6 May 2010 08:37:41 +0000 (08:37 +0000)
NEWS
ext/pdo/pdo_dbh.c
ext/pdo/pdo_stmt.c
ext/pdo/php_pdo_driver.h

diff --git a/NEWS b/NEWS
index 83894870d4d664c02d72f2291417e5e5ab22fe27..ae305a84b5ec056aae967968b6dbbfa2b9ce51ce 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -49,7 +49,9 @@
   . session_is_registered(), session_register() and session_unregister() 
     functions. (Kalle)
   . y2k_compliance ini option. (Kalle)
-       
+
+- Fixed PDO objects binary incompatibility. (Dmitry)
+       
 ?? ??? 20??, PHP 5.3.3
 - Upgraded bundled PCRE to version 8.01. (Ilia)
 
index c916dc099cbc7e34ee00656b02f848f8c3b4bb4c..bbb43a8619b3b15886a339f50673b7eecdb3f034 100755 (executable)
@@ -328,20 +328,20 @@ static PHP_METHOD(PDO, dbh_constructor)
                                memcpy((char *)pdbh->persistent_id, hashkey, plen+1);
                                pdbh->persistent_id_len = plen+1;
                                pdbh->refcount = 1;
-                               pdbh->properties = NULL;
+                               pdbh->std.properties = NULL;
                        }
                }
 
                if (pdbh) {
                        /* let's copy the emalloc bits over from the other handle */
-                       if (pdbh->properties) {
-                               zend_hash_destroy(dbh->properties);     
-                               efree(dbh->properties);
+                       if (pdbh->std.properties) {
+                               zend_hash_destroy(dbh->std.properties); 
+                               efree(dbh->std.properties);
                        } else {
-                               pdbh->ce = dbh->ce;
+                               pdbh->std.ce = dbh->std.ce;
                                pdbh->def_stmt_ce = dbh->def_stmt_ce;
                                pdbh->def_stmt_ctor_args = dbh->def_stmt_ctor_args;
-                               pdbh->properties = dbh->properties;
+                               pdbh->std.properties = dbh->std.properties;
                        }
                        /* kill the non-persistent thingamy */
                        efree(dbh);
@@ -1286,7 +1286,7 @@ int pdo_hash_methods(pdo_dbh_t *dbh, int kind TSRMLS_DC)
                ifunc->type = ZEND_INTERNAL_FUNCTION;
                ifunc->handler = funcs->handler;
                ifunc->function_name = (char*)funcs->fname;
-               ifunc->scope = dbh->ce;
+               ifunc->scope = dbh->std.ce;
                ifunc->prototype = NULL;
                if (funcs->arg_info) {
                        ifunc->arg_info = (zend_arg_info*)funcs->arg_info + 1;
@@ -1539,16 +1539,12 @@ static void pdo_dbh_free_storage(pdo_dbh_t *dbh TSRMLS_DC)
                dbh->methods->rollback(dbh TSRMLS_CC);
                dbh->in_txn = 0;
        }
-
-       if (dbh->properties) {
-               zend_hash_destroy(dbh->properties);
-               efree(dbh->properties);
-               dbh->properties = NULL;
-       }
        
        if (dbh->is_persistent && dbh->methods && dbh->methods->persistent_shutdown) {
                dbh->methods->persistent_shutdown(dbh TSRMLS_CC);
        }
+       zend_object_std_dtor(&dbh->std TSRMLS_CC);
+       dbh->std.properties = NULL;
        dbh_free(dbh TSRMLS_CC);
 }
 
@@ -1560,11 +1556,9 @@ zend_object_value pdo_dbh_new(zend_class_entry *ce TSRMLS_DC)
 
        dbh = emalloc(sizeof(*dbh));
        memset(dbh, 0, sizeof(*dbh));
-       dbh->ce = ce;
+       zend_object_std_init(&dbh->std, ce TSRMLS_CC);
+       zend_hash_copy(dbh->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
        dbh->refcount = 1;
-       ALLOC_HASHTABLE(dbh->properties);
-       zend_hash_init(dbh->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
-       zend_hash_copy(dbh->properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
        dbh->def_stmt_ce = pdo_dbstmt_ce;
        
        retval.handle = zend_objects_store_put(dbh, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)pdo_dbh_free_storage, NULL TSRMLS_CC);
index 1213722bcad5350759a44c4bdea50d884035a840..40d10c54b3fb8b33ddaf40f1d6815b9d44e4eaef 100755 (executable)
@@ -2319,11 +2319,9 @@ static zend_object_value dbstmt_clone_obj(zval *zobject TSRMLS_DC)
        zend_object_handle handle = Z_OBJ_HANDLE_P(zobject);
 
        stmt = ecalloc(1, sizeof(*stmt));
-       stmt->ce = Z_OBJCE_P(zobject);
+       zend_object_std_init(&stmt->std, Z_OBJCE_P(zobject) TSRMLS_CC);
+       zend_hash_copy(stmt->std.properties, &stmt->std.ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
        stmt->refcount = 1;
-       ALLOC_HASHTABLE(stmt->properties);
-       zend_hash_init(stmt->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
-       zend_hash_copy(stmt->properties, &stmt->ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
 
        old_stmt = (pdo_stmt_t *)zend_object_store_get_object(zobject TSRMLS_CC);
        
@@ -2366,12 +2364,6 @@ void pdo_stmt_init(TSRMLS_D)
 
 static void free_statement(pdo_stmt_t *stmt TSRMLS_DC)
 {
-       if (stmt->properties) {
-               zend_hash_destroy(stmt->properties);
-               efree(stmt->properties);
-               stmt->properties = NULL;
-       }
-
        if (stmt->bound_params) {
                zend_hash_destroy(stmt->bound_params);
                FREE_HASHTABLE(stmt->bound_params);
@@ -2420,6 +2412,7 @@ static void free_statement(pdo_stmt_t *stmt TSRMLS_DC)
        if (stmt->dbh) {
                php_pdo_dbh_delref(stmt->dbh TSRMLS_CC);
        }
+       zend_object_std_dtor(&stmt->std TSRMLS_CC);
        efree(stmt);
 }
 
@@ -2448,11 +2441,9 @@ zend_object_value pdo_dbstmt_new(zend_class_entry *ce TSRMLS_DC)
        pdo_stmt_t *stmt;
        stmt = emalloc(sizeof(*stmt));
        memset(stmt, 0, sizeof(*stmt));
-       stmt->ce = ce;
+       zend_object_std_init(&stmt->std, ce TSRMLS_CC);
+       zend_hash_copy(stmt->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
        stmt->refcount = 1;
-       ALLOC_HASHTABLE(stmt->properties);
-       zend_hash_init(stmt->properties, 0, NULL, ZVAL_PTR_DTOR, 0);
-       zend_hash_copy(stmt->properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
 
        retval.handle = zend_objects_store_put(stmt, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)pdo_dbstmt_free_storage, (zend_objects_store_clone_t)dbstmt_clone_obj TSRMLS_CC);
        retval.handlers = &pdo_dbstmt_object_handlers;
@@ -2694,10 +2685,10 @@ static HashTable *row_get_properties(zval *object TSRMLS_DC)
                MAKE_STD_ZVAL(val);
                fetch_value(stmt, val, i, NULL TSRMLS_CC);
 
-               zend_hash_update(stmt->properties, stmt->columns[i].name, stmt->columns[i].namelen + 1, (void *)&val, sizeof(zval *), NULL);
+               zend_hash_update(stmt->std.properties, stmt->columns[i].name, stmt->columns[i].namelen + 1, (void *)&val, sizeof(zval *), NULL);
        }
 
-       return stmt->properties;
+       return stmt->std.properties;
 }
 
 static union _zend_function *row_method_get(
index 06d09b2d17ae3b9f2f5394b9590a89b48d27a329..a9396c5a26df9b4df9e8f7d1e0dd19de954fcfc8 100755 (executable)
@@ -430,10 +430,7 @@ struct _pdo_dbh_t {
        to allow the extending class to escape all the custom handlers
           that PDO declares.
     */
-       zend_class_entry *ce; 
-       HashTable *properties;
-       unsigned int in_get:1;
-       unsigned int in_set:1;
+       zend_object std;
 
        /* driver specific methods */
        struct pdo_dbh_methods *methods;
@@ -548,10 +545,7 @@ struct _pdo_stmt_t {
        to allow the extending class to escape all the custom handlers
           that PDO declares.
     */
-       zend_class_entry *ce; 
-       HashTable *properties;
-       unsigned int in_get:1;
-       unsigned int in_set:1;
+       zend_object std;
 
        /* driver specifics */
        struct pdo_stmt_methods *methods;