]> granicus.if.org Git - php/commitdiff
implement the 'request shutdown' hook; this allows us to register UDFs on
authorWez Furlong <wez@php.net>
Fri, 10 Jun 2005 05:49:48 +0000 (05:49 +0000)
committerWez Furlong <wez@php.net>
Fri, 10 Jun 2005 05:49:48 +0000 (05:49 +0000)
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.

ext/pdo_sqlite/sqlite_driver.c

index 13fee3acd2d20683f76c3ac1f3ef8e1d331f7d8d..14957b3ffbe4951e93a2c91aee04a6977f10b243 100644 (file)
@@ -469,11 +469,6 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
        
        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 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
        
        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 function_entry *get_driver_methods(pdo_dbh_t *dbh, int kind TSRMLS_DC)
        }
 }
 
+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 @@ static struct pdo_dbh_methods sqlite_methods = {
        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)