Make WordPress Core

Opened 14 years ago

Closed 11 years ago

Last modified 9 years 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's profile 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 14 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 14 years ago.
Another screen shot of the comments page filled with warnings.
screenshot-notices.jpg (178.9 KB) - added by frumph 13 years 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 13 years ago.
notices in the comments section of the wp-admin

Download all attachments as: .zip

Change History (21)

@grandslambert
14 years ago

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

@grandslambert
14 years ago

Another screen shot of the comments page filled with warnings.

#1 @ocean90
14 years ago

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

Do you have deactivated all your plugins?

#2 @scribu
14 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

#3 @grandslambert
14 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.

#4 @ocean90
14 years ago

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

#5 @grandslambert
14 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.

#6 @ocean90
14 years ago

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

Okay, thanks.

#7 @frumph
13 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

@frumph
13 years ago

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

#8 @frumph
13 years 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 13 years ago by frumph (previous) (next) (diff)

@frumph
13 years ago

notices in the comments section of the wp-admin

#9 @frumph
13 years ago

  • Cc philip@… added

#10 @nacin
13 years 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.

#11 @frumph
13 years 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' );

#12 @scribu
13 years 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'.

#13 @SergeyBiryukov
13 years ago

  • Milestone set to Awaiting Review

Related: ticket:19590:12

#15 @wonderboymusic
11 years ago

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

#16 @nacin
11 years 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.

This ticket was mentioned in Slack in #core by miguelsmuller. View the logs.


9 years ago

Note: See TracTickets for help on using tickets.