• Resolved usama sulaiman

    (@usama-sulaiman)


    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 in wp-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 int

    Note 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

Viewing 1 replies (of 1 total)
  • Thread Starter usama sulaiman

    (@usama-sulaiman)

    Finally I fix the problem

    I keep tracking every where in my code and start to comment my code parts step by step.

    I was using upload form and also get image from link, and that was the main problem a conflict between uploading using upload form and using image link

    So when I comment the function which I’m using to upload image from PC the code work perfectly

Viewing 1 replies (of 1 total)
  • The topic ‘Object of class WP_Error could not be converted to int _get_non_cached_ids’ is closed to new replies.