Category search throws PHP exception when search returns category children
|Reported by:||gortsleigh||Owned by:|
"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.
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".