Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The structure of the query in the hook_uninstall function could delete unintended variables from the variable table.
/**
* Remove variables on uninstall.
*/
function backup_migrate_uninstall() {
db_query("DELETE FROM {variable} WHERE name LIKE 'backup_migrate_%'");
db_query("DELETE FROM {variable} WHERE name LIKE 'nodesquirrel_%'");
cache_clear_all('variables', 'cache');
}
The underscore is a wildcard character in this scenario, so the query will delete the following variables:
- nodesquirrel_var_to_delete
- backup_migrate_var_to_delete
- backup_migrated_files
- nodesquirrelsareawesome
The underscore character should be escaped, or the db_like() function should be used.
Documentation on db_like details the underscore as a wildcard issue https://api.drupal.org/api/drupal/includes%21database%21database.inc/fun...
Comment | File | Size | Author |
---|---|---|---|
#2 | backup_migrate-2831470-2.patch | 821 bytes | Snehal Brahmbhatt |
|
Comments
Comment #2
Snehal Brahmbhatt CreditAttribution: Snehal Brahmbhatt at AddWeb Solution Pvt. Ltd. commented@bfodeke, While uninstalling module , it deletes all variables using query. I've changed the way to delete variable using variable_del as per requirement. Changes are done in backup_migrate.install (function backup_migrate_uninstall()). PFA
Thanks!,
Comment #3
DamienMcKenna@snehal.addweb: One of your coworkers came up with an identical patch in #2939172: List out each individual variable in backup_migrate_uninstall(). Well go with this issue though and just credit them here.
Comment #5
DamienMcKennaComment #6
DamienMcKennaComment #8
DamienMcKennaCommitted. Thanks.