From d0c4c4c3348f28ea263296bede4912049344af64 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sat, 20 Jul 2013 20:16:21 +0000 Subject: [PATCH] Check that we have a database connection in wpdb::_real_escape(). see #24773. git-svn-id: https://develop.svn.wordpress.org/trunk@24758 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/wp-db.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 16230ae493..4f5a97eb47 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -876,7 +876,12 @@ class wpdb { * @return string escaped */ function _real_escape( $string ) { - return mysql_real_escape_string( $string, $this->dbh ); + if ( $this->dbh ) + return mysql_real_escape_string( $string, $this->dbh ); + + $class = get_class( $this ); + _doing_it_wrong( $class, "$class must set a database connection for use with escaping.", E_USER_NOTICE ); + return addslashes( $string ); } /**