Opened 2 years ago
Last modified 5 months ago
#16651 reopened defect (bug)
Warnings on dashboard: Notice: Trying to get property of non-object in wp-includes/capabilities.php
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Warnings/Notices | Version: | 3.0 |
| Severity: | normal | Keywords: | |
| Cc: | philip@… |
Description
I just upgraded a local install to 3.1 and have the debug mode on. Now, on the dashboard the "Recent Comments" box is filled with notices. I will attach a screen-shot of the notices. Though this doesn't show when debug mode is off, I have to assume that something isn't working with all of these warnings.
Attachments (4)
Change History (18)
grandslambert — 2 years ago
- Component changed from General to Warnings/Notices
- Keywords reporter-feedback added
Do you have deactivated all your plugins?
Those notices are most likely caused by a plugin doing something wrong.
Put the following gist in your mu-plugins folder to see a backtrace. https://gist.github.com/625769
comment:3
grandslambert — 2 years ago
OK, I did a clean install of 3.1 and turned on debug mode and it does not happen. Went back to other install and removed all plugins, still happens. Then I noticed there were some comments for posts that were no longer on the site. Once I deleted those from the database the errors went away. Apparently another bug which I may not be able to track prevented these comments from deleting when the posts were deleted. I will look into that, but perhaps a check to make sure a comment is associated with a post could prevent these errors -though it is not likely to happen all that often.
grandslambert, would be nice if you can add the backtrace (see scribu's comment) to investigate it.
comment:5
grandslambert — 2 years ago
How would that help me if there are no errors showing now? The problem was bad data, likely caused by a bad plugin, and certainly not something that should be the concern of WordPress core developers. I doubt very much that any other user is going to encounter this problem.
- Keywords reporter-feedback removed
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Okay, thanks.
- Version changed from 3.1 to 3.4
Reopening this ticket, I'm having the same situation.
Twentyeleven, no plugins activated.
Although I had a plugin enabled that created a custom post type, that has comments on their custom post type posts.
More Info: I had attempted to import the "theme unit test" which had issues and failures importing, couldn't retrieve images etc.
comment:10
nacin — 12 months ago
- Version changed from 3.4 to 3.0
Okay, based on the description, this should be reproducible back to 3.0.
So the issue is two-fold:
- What to do about comments on a post of a non-existent type? and
- map_meta_cap() needs to be a bit more resilient here.
comment:11
frumph — 12 months ago
Is it possible to do a check under the call for get_post_type_object, since it returns null we can gather that it must have existed at some point in time and then refer to using say 'post' as a fallback for the meta_cap ? -- probably could be done cleaner in the function get_post_type_object()
if (is_null($post_type_object)) $post_type_object = get_post_type_object( 'post' );
comment:12
scribu — 12 months ago
I don't think we should default to 'post' if the CPT is null.
IMO, the cap check should fail, unless the user has 'moderate_comments'.
Related: #21031

Screenshot of warning notices in the Recent Comments box on the dashboard in 3.1