﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
16446	Edgecase bug within wp_count_comments()	ptahdunbar		"I'm getting the following error:
{{{
Notice: Undefined index: ignored in /Users/ptah/Sites/wordpress/wp.dev/wp-includes/comment.php on line 833
}}}


This happens because on line 826 of wp-includes/comments.php WordPress is running the following code:

{{{
$approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed');
$known_types = array_keys( $approved );
foreach ( (array) $count as $row ) {
	// Don't count post-trashed toward totals
	if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] )
		$total += $row['num_comments'];
	if ( in_array( $row['comment_approved'], $known_types ) )
		$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
}
}}}

The second if statement is where the offending code happens.

Sometimes comments have a comment_approved value of 'ignored' and because $known_types has integers within that array, 'ignored' gets converted into an integer resulting in in_array returning true when it should be false.. thus comes our notice.

To fix this, in_array() needs to be running in strict mode so theirs no conversions."	defect (bug)	closed	normal		Administration	3.0	trivial	duplicate		
