• Resolved VGJ

    (@vgj)


    I have found a PHP Notice (Array to string conversion in wp-includes/post.php) when using strict. The notice is for cpt-onomies/manager.php at line 340. It seems that there does not seem to be any thought of $query->query['post_type'] being an array. It fails at post_type_exists( $query->query[ 'post_type' ] ). The function post_type_exists() returns a boolean based on get_post_type_object() which forces the passed variable into a string.

    You can see below:

    function post_type_exists( $post_type ) {
           return (bool) get_post_type_object( $post_type );
    }
    
    function get_post_type_object( $post_type ) {
            global $wp_post_types;
    
            <strong>if ( empty($wp_post_types["" . $post_type]) )</strong>
                    return null;
    
            return $wp_post_types[$post_type];
    }

    I just wanted to bring this to your attention. I am thinking that if it is an array check if more than one type. If it is not, than send the string. If it is than check if it only contains one item. If so, return that string for the check. If it is larger …. ??? Maybe just exit as cpt-onomies would not work?

    https://wordpress.org/plugins/cpt-onomies/

Viewing 1 replies (of 1 total)
  • Have you updated to 1.3.3 that I released this morning? It should take care of this. Please let me know if it does not.

    Thanks for letting me know!

Viewing 1 replies (of 1 total)

The topic ‘PHP Notice: Array to string conversion in wp-includes/post.php’ is closed to new replies.