WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#15215 closed defect (bug) (fixed)

wp_count_comments throws Error Notice for unknown comment_approved types

Reported by: batmoo Owned by: ryan
Milestone: 3.2 Priority: normal
Severity: normal Version: 3.0.1
Component: Comments Keywords: has-patch 3.2-early
Focuses: Cc:

Description

If you have any comments with a comment_approved value of an "unknown type" (i.e. anything other than '0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'), wp_count_comments throws an error notice.

Notice: Undefined index: 'my-custom-approved' in /Users/moo/Sites/dev/WordPress/wp-includes/comment.php on line 858

Setting the in_array check to strict, fixes the error.

Attachments (2)

wp_count_comments.15215.diff (586 bytes) - added by batmoo 11 years ago.
3.1-wp_count_comments.patch (772 bytes) - added by tfnab 10 years ago.
Alternative way of fixing this; patch for 3.1 which has the same issue

Download all attachments as: .zip

Change History (10)

#1 @batmoo
11 years ago

  • Cc batmoo@… added
  • Keywords has-patch added

Patch sets in_array check on wp_count_comments to strict.

#2 @dd32
10 years ago

  • Keywords 3.2-early added
  • Milestone changed from Awaiting Review to Future Release

#3 @markjaquith
10 years ago

Would really be nice to have full support for custom comment statuses. You can't really do it properly now.

#4 @hakre
10 years ago

+1 Patch looks good in my eyes, strict check is reasonable. Everything else can be done in an additional ticket if there really is a want for it.

@tfnab
10 years ago

Alternative way of fixing this; patch for 3.1 which has the same issue

#5 @tfnab
10 years ago

+1
Please re-consider fixing this ASAP, i.e. before 3.2, but maybe with another minor version number release, as this has me changing core to avoid the notices thrown, and it makes the update process much more annoying (but I want to stay updated in case of any security issues)!

Thank you.

I've added another patch that removes the unneccessary $known_types variable

#6 @nacin
10 years ago

Notices aren't enough for point releases. Especially for API usage that is technically unsupported.

#7 @nacin
10 years ago

  • Milestone changed from Future Release to 3.2

#8 @ryan
10 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [17795]:

Fix notice thrown in wp_count_comments(). Props tfnab, batmoo. fixes #15215

Note: See TracTickets for help on using tickets.