Make WordPress Core

Opened 16 years ago

Closed 15 years ago

#15215 closed defect (bug) (fixed)

wp_count_comments throws Error Notice for unknown comment_approved types

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

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 16 years ago.
3.1-wp_count_comments.patch (772 bytes ) - added by tfnab 15 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
16 years ago

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

Patch sets in_array check on wp_count_comments to strict.

#2 @dd32
16 years ago

  • Keywords 3.2-early added
  • Milestone Awaiting ReviewFuture Release

#3 @markjaquith
16 years ago

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

#4 @hakre
15 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
15 years ago

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

#5 @tfnab
15 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
15 years ago

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

#7 @nacin
15 years ago

  • Milestone Future Release3.2

#8 @ryan
15 years ago

  • Owner set to ryan
  • Resolutionfixed
  • Status newclosed

In [17795]:

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

Note: See TracTickets for help on using tickets.