Thread

Error when deleting an empty category group when category_delete hook is used

February 19, 2014 8:40am

Subscribe [2]
  • #1 / Feb 19, 2014 8:40am

    Low's avatar

    Low

    371 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);
    }
    //
    // -------------------------------------------
  • #2 / Feb 19, 2014 2:13pm

    Kevin Cupp's avatar

    Kevin Cupp

    637 posts

    Thanks, Low! Got it fixed.

ExpressionEngine News

#eecms, #events, #releases