diff -urNp /tmp/drupal-4.7.4/includes/database.mysqli.inc includes/database.mysqli.inc --- /tmp/drupal-4.7.4/includes/database.mysqli.inc 2006-09-26 07:14:33.000000000 -0700 +++ includes/database.mysqli.inc 2006-11-13 15:14:18.000000000 -0800 @@ -76,16 +76,6 @@ function db_connect($url) { /* Force UTF-8 */ mysqli_query($connection, 'SET NAMES "utf8"'); - /** - * from: http://bugs.php.net/bug.php?id=33772 - * Write and Close handlers are called after destructing objects since PHP - * 5.0.5. Thus destructors can use sessions but session handler can't use - * objects. In prior versions, they were called in the opposite order. It - * is possible to call session_write_close() from the destructor to solve - * this chicken and egg problem. - */ - register_shutdown_function('session_write_close'); - return $connection; } diff -urNp /tmp/drupal-4.7.4/includes/session.inc includes/session.inc --- /tmp/drupal-4.7.4/includes/session.inc 2006-04-11 04:33:14.000000000 -0700 +++ includes/session.inc 2006-11-13 15:01:04.000000000 -0800 @@ -17,6 +17,11 @@ function sess_close() { function sess_read($key) { global $user; + // Write and Close handlers are called after destructing objects since PHP 5.0.5 + // Thus destructors can use sessions but session handler can't use objects. + // So we are moving session closure before destructing objects. + register_shutdown_function('session_write_close'); + // retrieve data for a $user object $result = db_query("SELECT sid FROM {sessions} WHERE sid = '%s'", $key); if (!db_num_rows($result)) {