diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index 92c534e..e88aacf 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -1322,6 +1322,9 @@ function system_modules_uninstall_submit($form, &$form_state) { drupal_set_message(t('The selected modules have been uninstalled.')); $form_state['redirect'] = 'admin/modules/uninstall'; + + // Synchronize actions to remove all related to uninstalled modules. + actions_synchronize(); } else { $form_state['storage'] = $form_state['values']; diff --git a/modules/trigger/trigger.install b/modules/trigger/trigger.install index 7dded60..1bb66e3 100644 --- a/modules/trigger/trigger.install +++ b/modules/trigger/trigger.install @@ -45,9 +45,15 @@ function trigger_schema() { } /** - * Implements hook_install(). + * Implements hook_enable(). + * + * Removes all assigned orphaned actions while the module has been disabled. */ -function trigger_install() { - // Do initial synchronization of actions in code and the database. - actions_synchronize(); +function trigger_enable() { + // Synchronize {trigger_assignments} table with a current set of actions. + $select = db_select('actions') + ->fields('actions', array('aid')); + db_delete('trigger_assignments') + ->condition('aid', $select, 'NOT IN') + ->execute(); } diff --git a/modules/trigger/trigger.test b/modules/trigger/trigger.test index 9a9a4ba..101b173 100644 --- a/modules/trigger/trigger.test +++ b/modules/trigger/trigger.test @@ -729,6 +729,7 @@ class TriggerOrphanedActionsTestCase extends DrupalWebTestCase { // Disable the module that provides the action and make sure the trigger // doesn't white screen. module_disable(array('trigger_test')); + variable_set('trigger_test_generic_any_action', 0); $loaded_node = $this->drupalGetNodeByTitle($edit["title"]); $edit["body[$langcode][0][value]"] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32); $this->drupalPost("node/$loaded_node->nid/edit", $edit, t('Save')); @@ -736,5 +737,7 @@ class TriggerOrphanedActionsTestCase extends DrupalWebTestCase { // If the node body was updated successfully we have dealt with the // unavailable action. $this->assertRaw(t('!post %title has been updated.', array('!post' => 'Basic page', '%title' => $edit["title"])), t('Make sure the Basic page can be updated with the missing trigger function.')); + // Action should not have been fired. + $this->assertFalse(variable_get('trigger_test_generic_any_action', 0), t('Trigger test action has not been fired.')); } }