From eb822723aea392bad75345b5af87e1780493d5d0 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: http://core.svn.wordpress.org/trunk@24758 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 ); } /**