WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 months ago

#16651 closed defect (bug) (duplicate)

Warnings on dashboard: Notice: Trying to get property of non-object in wp-includes/capabilities.php

Reported by: grandslambert Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Role/Capability Keywords: needs-patch
Focuses: Cc:

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)

Screenshot-26.png (61.5 KB) - added by grandslambert 3 years ago.
Screenshot of warning notices in the Recent Comments box on the dashboard in 3.1
Screenshot-27.png (123.1 KB) - added by grandslambert 3 years ago.
Another screen shot of the comments page filled with warnings.
screenshot-notices.jpg (178.9 KB) - added by frumph 23 months ago.
Screenshots of notices in the exact place as above, but with ver 3.4
screenshot-notices-comments.jpg (120.8 KB) - added by frumph 23 months ago.
notices in the comments section of the wp-admin

Download all attachments as: .zip

Change History (20)

grandslambert3 years ago

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

grandslambert3 years ago

Another screen shot of the comments page filled with warnings.

comment:1 ocean903 years ago

  • Component changed from General to Warnings/Notices
  • Keywords reporter-feedback added

Do you have deactivated all your plugins?

comment:2 scribu3 years ago

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 grandslambert3 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.

comment:4 ocean903 years ago

grandslambert, would be nice if you can add the backtrace (see scribu's comment) to investigate it.

comment:5 grandslambert3 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.

comment:6 ocean903 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Okay, thanks.

comment:7 frumph23 months ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

frumph23 months ago

Screenshots of notices in the exact place as above, but with ver 3.4

comment:8 frumph23 months ago

  • 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.

Version 1, edited 23 months ago by frumph (previous) (next) (diff)

frumph23 months ago

notices in the comments section of the wp-admin

comment:9 frumph23 months ago

  • Cc philip@… added

comment:10 nacin23 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:

  1. What to do about comments on a post of a non-existent type? and
  2. map_meta_cap() needs to be a bit more resilient here.

comment:11 frumph23 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 scribu23 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'.

comment:13 SergeyBiryukov23 months ago

  • Milestone set to Awaiting Review

Related: ticket:19590:12

comment:15 wonderboymusic7 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

comment:16 nacin3 months ago

  • Component changed from Warnings/Notices to Role/Capability
  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from reopened to closed

Duplicate of #19590.

Note: See TracTickets for help on using tickets.