我在设置功能图片时出现问题,我在同一页面中使用类似的提交几次在管理区域外提交帖子而没有收到任何错误,只有这个提交表单。
跟踪错误报告后,我发现问题_get_non_cached_ids
处于wp-includes/functions.php on line 3816
(二十二主题)
错误说:Object of class WP_Error could not be converted to int
当我测试它时,我得到了it is not int
,然后我尝试发现错误的函数框
在我的测试代码
下的_get_non_cached_ids
函数下面
/**
* Retrieve ids that are not already present in the cache
*
* @since 3.4.0
*
* @param array $object_ids ID list
* @param string $cache_key The cache bucket to check against
*
* @return array
*/
function _get_non_cached_ids( $object_ids, $cache_key ) {
$clean = array();
foreach ( $object_ids as $id ) {
/* my test start */
if ( is_wp_error( $id ) ) {
$error_string = $id->get_error_message();
echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
exit;
}else{
echo 'id is ok';
exit;
}
/* my test end */
$id = (int) $id;
if ( !wp_cache_get( $id, $cache_key ) ) {
$clean[] = $id;
}
}
return $clean;
}
我尝试了代码并收到一条消息说:
No file was uploaded.
如何上传文件,即使图片已成功上传并附加到帖子中,但它未显示为Featured image
并且在编辑帖子的管理区域中我在功能图像区域中出现错误:
Object of class WP_Error could not be converted to int in SITE_ROOT/public_html/wp-includes/post.php on line 4294
我测试is_int是否为int
请注意<{1}}中的,只有在出现问题时才会退出,这意味着如果没有问题,代码就不会输入_get_non_cached_ids
功能在所有
答案 0 :(得分:0)
经过数百次测试后,我的代码每一块都运行了,最后is_wp_error($id) returns id is ok
来自PC功能的上传图片中出现未知错误,这与链接上传图片冲突,但现在它正在工作,这就是我收到错误消息的原因:No file was uploaded