Hi the following variables are set when we save the "Indeed Search settings" form. The same are not deleted when we uninstall the module,

  1. indeed_country
  2. indeed_l
  3. indeed_limit
  4. indeed_pubid
  5. indeed_q
  6. indeed_radius
  7. indeed_sort
CommentFileSizeAuthor
#8 clean_up_variables_on-2851888-8.patch763 bytesjaykandari

Comments

vishwac9 created an issue. See original summary.

vishwac9’s picture

Issue tags: +Novice

Proposed solutions :-

Implement hook_uninstall().

   function indeed_search_uninstall() {
      db_delete('variable')
       ->condition('name', 'indeed_%', 'like')
       ->execute();
   }
vishwac9’s picture

Inorder to fix this issue there is another issue regarding the .install file name which needs to be fixed first. Incorrect file name

dishabhadra’s picture

Hi Vishwa,

For above issue you have mention Proposed solutions, So according to me this is not as per drupal Standards.

In db_delete you have mention condition('name' , 'indeed_%' , 'like') so there is risk in this condition, if we have any other module whose name is similiar to indeed and they have simillar kind of variable then as per this query they will also deleted.

So we can use variable_del($name) function and delete the variable.

Else we should rename the Variable name to 'modulename_country'. Eg. 'indeed_search_country' instead of 'indeed_country'.

vishwac9’s picture

hi dishabhadra you have a point, just thought instead of writing 7 variable delete which would again involve 7 different queries to the database to delete the variables lets do it in one single query.

swarad07’s picture

@Disha is correct, the correct way to do it would be via variable_del(). The API does more than just a delete query.

function variable_del($name) {
  global $conf;

  db_delete('variable')
    ->condition('name', $name)
    ->execute();
  cache_clear_all('variables', 'cache_bootstrap');

  unset($conf[$name]);
}
jaykandari’s picture

Assigned: Unassigned » jaykandari
jaykandari’s picture

Assigned: jaykandari » Unassigned
Status: Active » Needs review
StatusFileSize
new763 bytes

Implemented hook_uninstall() in indeed_serach.install file.

apply this patch before committing #2851891: Incorrect filename .

dishabhadra’s picture

Status: Needs review » Reviewed & tested by the community

@JayKandari : Thank you for the patch. It looks good to me.

gaurav.kapoor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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