Object of class WP_Error could not be converted to int _get_non_cached_ids
-
I’m having a problem with setting feature image, I am using the similar submit several times in the same page to submit post outside the admin area and not getting any errors, only this submit form.
After tracing errors report I found the problem with
_get_non_cached_ids
function which is inwp-includes/functions.php
on line 3816 (twentyeleven
theme)Error says:
Object of class WP_Error could not be converted to int
When I test it I got that it is not int, then I try to discover the function casing that error
Below the _get_non_cached_ids function with my test code
/**
* 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;
}I tried the code and got a message saying:
No file was uploaded.
HOW NO FILE WAS UPLOADED even the image uploaded successfully and attached to the post, but it didn’t appear as Featured image
and in the admin area for edit post I got an error in the Feature image area says:
Object of class WP_Error could not be converted to int in SITE_ROOT/public_html/wp-includes/post.php on line 4294
I test if
is_int
and I found it is intNote that in the _get_non_cached_ids, exit happening only if there is a problem, which means that if there is no problem the code don’t enter to _get_non_cached_ids function at all
- The topic ‘Object of class WP_Error could not be converted to int _get_non_cached_ids’ is closed to new replies.