Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Once a minute I get the following notice sequence in debug.log:

[23-Oct-2012 13:27:33 UTC] PHP Notice:  Trying to get property of non-object in mysite/wp-includes/capabilities.php on line 1022
[23-Oct-2012 13:27:33 UTC] PHP Notice:  Trying to get property of non-object in mysite/wp-includes/capabilities.php on line 1023
[23-Oct-2012 13:27:33 UTC] PHP Notice:  Trying to get property of non-object in mysite/wp-includes/capabilities.php on line 1023
[23-Oct-2012 13:27:33 UTC] PHP Notice:  Trying to get property of non-object in mysite/wp-includes/capabilities.php on line 1026
[23-Oct-2012 13:27:33 UTC] PHP Notice:  Trying to get property of non-object in mysite/wp-includes/capabilities.php on line 1026
[23-Oct-2012 13:27:35 UTC] PHP Notice:  Trying to get property of non-object in mysite/wp-includes/capabilities.php on line 1022
[23-Oct-2012 13:27:35 UTC] PHP Notice:  Trying to get property of non-object in mysite/wp-includes/capabilities.php on line 1023
[23-Oct-2012 13:27:35 UTC] PHP Notice:  Trying to get property of non-object in mysite/wp-includes/capabilities.php on line 1023
[23-Oct-2012 13:27:35 UTC] PHP Notice:  Trying to get property of non-object in mysite/wp-includes/capabilities.php on line 1026
[23-Oct-2012 13:27:35 UTC] PHP Notice:  Trying to get property of non-object in mysite/wp-includes/capabilities.php on line 1026

I disabled all plugins and selected the default Twenty Eleven theme, but still get it. How can I troubleshoot this? I'm using WordPress 3.4.2.

share|improve this question
add comment

3 Answers 3

The actual "sequence" of notices is half of what you posted above (see the 2 second offset for one, and for another the repeating line numbers).

This notice is from the map_meta_cap() function which maps custom post type capabilities to the regular or primitive post related capabilities.

Here are lines 1020 through 1028 of /wp-includes/capabilities.php (as in 3.4.2):

$post_type = get_post_type_object( $post->post_type );

if ( ! $post_type->map_meta_cap ) {
    $caps[] = $post_type->cap->$cap;
    // Prior to 3.1 we would re-call map_meta_cap here.
    if ( 'edit_post' == $cap )
        $cap = $post_type->cap->$cap;
    break;
}

So what is technically happening is that in the first line of the above, the $post global does have a $post_type property, but when that is fed to get_post_type_object() the function fails and does not return a post type object.
Hence you get one notice from 1022 ($post_type->map_meta_cap), two from 1023 ($post_type->cap->$cap) and two from 1026 ($post_type->cap->$cap).

At this point I have to disappoint you though. What exactly is calling map_meta_cap(), whether from the core or not, and why the post type slug in question appears not to be a valid registered post type - I have no idea or suggestion.

share|improve this answer
    
Thank Johannes. I included both sequences for completeness as they always seem to come in pairs with one minute in between. I got the idea to delete browser cache, cookies etc. and the notices stopped. But reenabling plugins and the custom theme I'm using made it come back. I'll try to isolate it. –  seron Oct 23 '12 at 17:05
1  
"But reenabling plugins and the custom theme I'm using made it come back. I'll try to isolate it." That should tell you everything you need to know, eh? :) You've got an improperly-registered custom post type. –  Chip Bennett Dec 4 '12 at 16:25
add comment

You probably already figured this out, but I just had this issue and figured it out. Hopefully, if anyone runs into this problem, this may help.

My problem came from the Disqus Comment System plugin. Because I had used my Disqus user name to do some test comments on a dev site, when I linked my production site to the dev site, it created comments on test blog posts that didn't exist.

I had to go into the database and delete the comment rows that were attached to nonexistent post IDs, which fixed the problem for me.

share|improve this answer
add comment

You can try to add this code before your if statement:

if(is_object($post_type))
share|improve this answer
1  
Please add an explanation to your answer: why could that solve the problem? –  toscho Aug 14 '13 at 17:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.