EllisLab text mark
Advanced Search
     
Error when deleting an empty category group when category_delete hook is used
Posted: 19 February 2014 08:40 AM
Avatar
Joined: 2004-10-18
370 posts

Just came across this bug. When the category_delete hook is in use, and someone deletes an empty category group, you get a “$cat_ids is not defined” error. Here’s the code in category_model.php to fix it, starting from line #357:

// moved from inside the if-statement
$cat_ids = array();

if (
$query->num_rows() > 0)
{
 
// move this line up
 //$cat_ids = array();

 
foreach ($query->result() as $row)
 
{
  $cat_ids[] 
$row->cat_id;
 
}

 $this
->db->where_in('cat_id'$cat_ids);
 
$this->db->delete('category_posts');
}

// -------------------------------------------
// 'category_delete' hook.
//
if (ee()->extensions->active_hook('category_delete') === TRUE)
{
 ee
()->extensions->call('category_delete'$cat_ids);
}
//
// ------------------------------------------- 

Kevin Cupp
Administrator

2014-02-19 (0 votes) by Kevin Cupp

Thanks, Low! Got it fixed.

 Signature 

Low: the Pro Network member who brought you Low Variables, Low Search, Low Seg2Cat and many more...

 
Posted: 19 February 2014 02:13 PM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-17
611 posts

Thanks, Low! Got it fixed.

 Signature