Delete filter does not work

acidtalks - July 5, 2009 - 11:15
Project:Custom filter
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Issue tags:6.x-1.0-beta3, 6.x-2.0-beta1
Description

When deleting a filter with the "Delete" button under the tab "List filters" nothing happens. After the confirmation message you are back on the "List filters" page but the filter is not deleted.

This issue occured in the 6.x-1.0 branch, too.

-- Tim

#1

KiamLaLuno - July 5, 2009 - 13:05
Title:Delete Filter does not work» Delete filter does not work
Version:6.x-2.0-beta1» 6.x-2.x-dev

#2

KiamLaLuno - July 5, 2009 - 14:06
Status:active» postponed (maintainer needs more info)

That is strange, because the module contains the code to delete the filter data from the database.

Are you sure the form is not being cached? Did you check if your Drupal installation has the cache enabled?

Thanks for your report.

#3

acidtalks - July 5, 2009 - 15:23

Yes, code is there, but it uses an uninitialized variable $fid in function customfilter_filter_delete_submit:

db_query('DELETE FROM {customfilter_filters} WHERE fid = %d', $fid);

So the rules are deleted but not the filter.

A fix seems to be easy. Here's the code that works for me. Please review it.

function customfilter_filter_delete_submit($form, &$form_state) {
  $fid = $form_state['values']['fid'];
  $rules = customfilter_get_rules($fid);
 
  foreach ($rules as $rule) {
    customfilter_delete_rule($rule['rid']);
  }
 
  db_query('DELETE FROM {customfilter_filters} WHERE fid = %d', $fid);
 
  $form_state['redirect'] = 'admin/settings/filters/customfilter';
}

PS: Your module is great, saved me hours of time.

#4

acidtalks - July 5, 2009 - 15:29

Ok, I see you have already fixed this in the actual development tree. Installing the lasted version of customfilter-6.x-2.x has fixed the problem, too.

#5

KiamLaLuno - July 5, 2009 - 19:59
Status:postponed (maintainer needs more info)» active

Yes, I changed the code before to have an issue report. I updated the content of CHANGELOG.txt so it now contains a reference to this report.

I will then verify that also branch 6.x-1 doesn't contain the same kind of error; I need to take a break from developing new code because I start to see PHP code also in the electric grill (I don't know if that is a good, or a bad thing because I have never tasted broiled PHP).

#6

KiamLaLuno - July 5, 2009 - 20:34
Version:6.x-2.x-dev» 6.x-1.x-dev

Next time I should remember what I was doing, before to start to think of PH(is)H and chips.

#7

KiamLaLuno - July 6, 2009 - 02:31
Status:active» patch (to be ported)

#8

KiamLaLuno - July 8, 2009 - 04:26
Status:patch (to be ported)» fixed
Issue tags:+6.x-1.0-beta3

#9

System Message - July 22, 2009 - 04:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.