突然,我的 wordpress 项目的特定后端页面出现错误:
警告:wpdb::prepare() 缺少参数 2,在第 463 行的 .../wp-content/plugins/wpml-media/inc/wpml_media.class.php 中调用并在 .../wp-includes/ 中定义wp-db.php 在第 992 行
这将是:
wpml_media.class.php
// get language of their parents
if(!empty($missing_langs)){
$results = $wpdb->get_results($wpdb->prepare("
SELECT p.ID, t.language_code
FROM {$wpdb->posts} p JOIN {$wpdb->prefix}icl_translations t ON p.ID = t.element_id AND t.element_type = CONCAT('post_', p.post_type)
WHERE p.ID IN(".join(',', $missing_langs).")
"));
foreach($results as $row){
$parent_langs[$row->ID] = $row->language_code;
}
}
和wp-db.php
function prepare( $query, $args ) {
if ( is_null( $query ) )
return;
$args = func_get_args();
array_shift( $args );
// If args were passed as an array (as in vsprintf), move them up
if ( isset( $args[0] ) && is_array($args[0]) )
$args = $args[0];
$query = str_replace( "'%s'", '%s', $query ); // in case someone mistakenly already singlequoted it
$query = str_replace( '"%s"', '%s', $query ); // doublequote unquoting
$query = preg_replace( '|(?<!%)%f|' , '%F', $query ); // Force floats to be locale unaware
$query = preg_replace( '|(?<!%)%s|', "'%s'", $query ); // quote the strings, avoiding escaped strings like %%s
array_walk( $args, array( $this, 'escape_by_ref' ) );
return @vsprintf( $query, $args );
}
我不知道这里发生了什么,有什么想法吗?不幸的是,作者的支持已过期。
谢谢