From 5b4ebcdb25b25943c11921c9ee8b9904ef655cfd Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 18 Nov 2005 14:03:55 +0000 Subject: - Patch #36828 by m3avrck: some MySQLi fixes and some PHP5 fixes. --- includes/database.mysqli.inc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'includes') diff --git a/includes/database.mysqli.inc b/includes/database.mysqli.inc index f96f89659..7cad39921 100644 --- a/includes/database.mysqli.inc +++ b/includes/database.mysqli.inc @@ -22,10 +22,10 @@ */ function db_connect($url) { // Check if MySQLi support is present in PHP - if (!function_exists('mysqli_init')) { + if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) { drupal_maintenance_theme(); - drupal_set_title('PHP MySQL support not enabled'); - print theme('maintenance_page', '

We were unable to use the MySQL database because the MySQLi extension for PHP is not installed. Check your PHP.ini to see how you can enable it.

+ drupal_set_title('PHP MySQLi support not enabled'); + print theme('maintenance_page', '

We were unable to use the MySQLi database because the MySQLi extension for PHP is not installed. Check your PHP.ini to see how you can enable it.

For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.

'); exit; } @@ -71,6 +71,17 @@ function db_connect($url) { exit; } + + /** + * 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; } @@ -324,7 +335,8 @@ function db_decode_blob($data) { * Prepare user input for use in a database query, preventing SQL injection attacks. */ function db_escape_string($text) { - return mysql_real_escape_string($text); + global $active_db; + return mysqli_real_escape_string($active_db, $text); } -- cgit v1.2.3