summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-11-18 14:03:55 +0000
committerDries Buytaert <dries@buytaert.net>2005-11-18 14:03:55 +0000
commit5b4ebcdb25b25943c11921c9ee8b9904ef655cfd (patch)
treef34ad2d081c0a55e55a2c7d889ab11d66be64400
parent786f6b5ad9f1f06fb35b314c8566b9f5daf25b51 (diff)
downloadbrdo-5b4ebcdb25b25943c11921c9ee8b9904ef655cfd.tar.gz
brdo-5b4ebcdb25b25943c11921c9ee8b9904ef655cfd.tar.bz2
- Patch #36828 by m3avrck: some MySQLi fixes and some PHP5 fixes.
-rw-r--r--includes/database.mysqli.inc20
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);
}