Possible Duplicate:
Stackoverflow type of badge plugin giving warnings in Wordpress 3.5
I'm getting an error on my site that says:
Warning: Missing argument 2 for wpdb::prepare(), called in /home/blahblahblah/public_html/wp-content/mu-plugins/domain-mapping.php on line 489 and defined in /home/blahblahblah/public_html/wp-includes/wp-db.php on line 990
It's my understanding this is because now in WP 3.5 wpdb::prepare() requires you to use an array. Here is the offending code on line 489 of domain-mapping.php:
$olddomain = $this->db->get_var( $this->db->prepare( "SELECT option_value FROM {$this->db->options} WHERE option_name='siteurl' LIMIT 1 /* domain mapping */" ) );
How can I change this to be an array so it stops causing errors?
In this thread several other people had similar but different problems. There are fixes posted but I'm having trouble translating it into a solution for me.
If it helps to provide context here is the code for the whole function:
function swap_mapped_url($url, $path, $plugin = false) {
global $current_blog, $current_site, $mapped_id;
// To reduce the number of database queries, save the results the first time we encounter each blog ID.
static $swapped_url = array();
if ( !isset( $swapped_url[ $this->db->blogid ] ) ) {
$s = $this->db->suppress_errors();
$newdomain = $this->db->get_var( $this->db->prepare( "SELECT domain FROM {$this->dmt} WHERE domain = %s AND blog_id = %d LIMIT 1 /* domain mapping */", preg_replace( "/^www\./", "", $_SERVER[ 'HTTP_HOST' ] ), $this->db->blogid ) );
//$olddomain = str_replace($path, '', $url);
$olddomain = $this->db->get_var( $this->db->prepare( "SELECT option_value FROM {$this->db->options} WHERE option_name='siteurl' LIMIT 1 /* domain mapping */" ) );
if ( empty( $domain ) ) {
$domain = $this->db->get_var( $this->db->prepare( "SELECT domain FROM {$this->dmt} WHERE blog_id = %d /* domain mapping */", $this->db->blogid ) );
}
$this->db->suppress_errors( $s );
$protocol = ( 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://';
if ( $domain ) {
$innerurl = trailingslashit( $protocol . $domain . $current_site->path );
$newurl = str_replace($olddomain, $innerurl, $url);
$swapped_url[ $this->db->blogid ] = array($olddomain, $innerurl);
$url = $newurl;
} else {
$swapped_url[ $this->db->blogid ] = false;
}
} elseif ( $swapped_url[ $this->db->blogid ] !== FALSE) {
$olddomain = $swapped_url[ $this->db->blogid ][0];
$url = str_replace($olddomain, $swapped_url[ $this->db->blogid ][1], $url);
}
return $url;
}
