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
This commit is contained in:
Andrew Nacin 2013-07-20 20:16:21 +00:00
parent 17ce1a11f1
commit eb822723ae
1 changed files with 6 additions and 1 deletions

View File

@ -876,7 +876,12 @@ class wpdb {
* @return string escaped * @return string escaped
*/ */
function _real_escape( $string ) { 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 );
} }
/** /**