diff options
-rw-r--r-- | includes/database.mysqli.inc | 20 |
1 files changed, 16 insertions, 4 deletions
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', '<p>We were unable to use the MySQL database because the MySQLi extension for PHP is not installed. Check your <code>PHP.ini</code> to see how you can enable it.</p> + drupal_set_title('PHP MySQLi support not enabled'); + print theme('maintenance_page', '<p>We were unable to use the MySQLi database because the MySQLi extension for PHP is not installed. Check your <code>PHP.ini</code> to see how you can enable it.</p> <p>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>'); 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); } |