wez             Fri Jun 10 01:49:49 2005 EDT

  Modified files:              
    /php-src/ext/pdo_sqlite     sqlite_driver.c 
  Log:
  implement the 'request shutdown' hook; this allows us to register UDFs on
  persistent handles safely. (it is dangerous to keep them registered between
  requests, as there are 0 guarantees that functions with the same name are even
  present on the next hit, let alone that the zvals we cache point to the right
  place.
  
  
  
http://cvs.php.net/diff.php/php-src/ext/pdo_sqlite/sqlite_driver.c?r1=1.18&r2=1.19&ty=u
Index: php-src/ext/pdo_sqlite/sqlite_driver.c
diff -u php-src/ext/pdo_sqlite/sqlite_driver.c:1.18 
php-src/ext/pdo_sqlite/sqlite_driver.c:1.19
--- php-src/ext/pdo_sqlite/sqlite_driver.c:1.18 Fri Jun 10 01:17:47 2005
+++ php-src/ext/pdo_sqlite/sqlite_driver.c      Fri Jun 10 01:49:48 2005
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: sqlite_driver.c,v 1.18 2005/06/10 05:17:47 wez Exp $ */
+/* $Id: sqlite_driver.c,v 1.19 2005/06/10 05:49:48 wez Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -469,11 +469,6 @@
        
        dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
 
-       if (dbh->is_persistent) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "wont work on 
persistent handles");
-               RETURN_FALSE;
-       }
-
        if (!zend_is_callable(callback, 0, &cbname)) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is 
not callable", cbname);
                efree(cbname);
@@ -545,11 +540,6 @@
        
        dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
 
-       if (dbh->is_persistent) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "wont work on 
persistent handles");
-               RETURN_FALSE;
-       }
-
        if (!zend_is_callable(step_callback, 0, &cbname)) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "function '%s' is 
not callable", cbname);
                efree(cbname);
@@ -609,6 +599,16 @@
        }
 }
 
+static void pdo_sqlite_request_shutdown(pdo_dbh_t *dbh TSRMLS_DC)
+{
+       pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
+       /* unregister functions, so that they don't linger for the next
+        * request */
+       if (H) {
+               pdo_sqlite_cleanup_callbacks(H TSRMLS_CC);
+       }
+}
+
 static struct pdo_dbh_methods sqlite_methods = {
        sqlite_handle_closer,
        sqlite_handle_preparer,
@@ -622,7 +622,8 @@
        pdo_sqlite_fetch_error_func,
        pdo_sqlite_get_attribute,
        NULL,   /* check_liveness: not needed */
-       get_driver_methods
+       get_driver_methods,
+       pdo_sqlite_request_shutdown
 };
 
 static char *make_filename_safe(const char *filename TSRMLS_DC)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to