[wp-trac] [WordPress Trac] #9970: Category search throws PHP exception when search returns category children

WordPress Trac wp-trac at lists.automattic.com
Fri May 29 00:52:33 GMT 2009


#9970: Category search throws PHP exception when search returns category children
----------------------------+-----------------------------------------------
 Reporter:  gortsleigh      |       Owner:            
     Type:  defect (bug)    |      Status:  new       
 Priority:  normal          |   Milestone:  Unassigned
Component:  Administration  |     Version:  2.8       
 Severity:  normal          |    Keywords:            
----------------------------+-----------------------------------------------
 "Search Categories" in wp-admin/categories.php throws a warning
 {{{
 Warning: str_repeat(): Second argument has to be greater than or equal to
 0 in ..../wp-admin/includes/template.php on line 124
 }}}
 exception when the search results include child categories.

 To reproduce:

   Create category "Top Level"

   Create child categories "Child Level One" and "Child Level Two"

   Search for "level"

   Note: search for "top" will not generate the warning, because only the
 parent category is returned in the search results.

 The cause of the problem is that function _cat_row() is called with
 parameter $level set to -1 (level zero subtracted by number of parents).
 This happens only during a search; normally the level is set correctly.
 The included patch simply fixes the call to str_replace, not the value of
 the parameter passed to _cat_row()


 The purpose of the parameter is to aid in formatting the hierarchy of
 categories. Perhaps this should never be called with a negative value, but
 the formatting does not need to show hierarchy in search results, since it
 is likely the parents/ancestors will be missing from the results.

 So, I think this patch is "good enough".

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9970>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list