Possible Duplicate:
Stackoverflow type of badge plugin giving warnings in Wordpress 3.5
我的网站上出现一个错误,上面说:
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
这是我的理解
this is because now in WP 3.5 wpdb::prepare()
requires you to use an array. 下面是域映射的第489行的违规代码。php:
$olddomain = $this->db->get_var( $this->db->prepare( "SELECT option_value FROM {$this->db->options} WHERE option_name=\'siteurl\' LIMIT 1 /* domain mapping */" ) );
如何将其更改为数组,使其不再引起错误?
在里面this thread 其他几个人也有类似但不同的问题。发布了一些修复,但我很难将其转换为我的解决方案。
如果有助于提供上下文,那么下面是整个函数的代码:
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;
}