Orphaned assigned actions still triggered and cannot be removed

eMPee584 - September 10, 2008 - 15:52
Project:Drupal
Version:7.x-dev
Component:trigger.module
Category:bug report
Priority:critical
Assigned:Dave Reid
Status:needs work
Issue tags:actions
Description

just had this problem, here's the fix.

AttachmentSizeStatusTest resultOperations
trigger-fix-unassigning-removed-actions.patch1.32 KBIdleFailed: Failed to apply patch.View details | Re-test

#1

eMPee584 - September 10, 2008 - 15:55

ooops typo it should be 'even though they may still be assigned' .. . or might? anyhow, patch applies to D6/D7.

#2

Dave Reid - September 11, 2008 - 23:51

I just tried to verify this. I created an action 'redirect to url' and assigned it to a trigger. I then went and deleted the action under admin/settings/actions and the action was no longer under the admin/build/triggers screen. Looks like it was removed correctly. But, something interesting to know is that I still had a record in actions_aid for it. What exactly is the actions_aid table used for?

#3

Dave Reid - September 11, 2008 - 23:58
Status:needs review» postponed (maintainer needs more info)

In the meantime, going to mark this is as need more info since I couldn't duplicate this.

#4

eMPee584 - September 12, 2008 - 07:08

No no i don't mean deleting the action from the DB but from the function file! actions_list does a module_invoke_all('action_info') to receive the 'aids'...

#5

Dave Reid - September 12, 2008 - 20:26

Can you list the exact steps I can take to help reproduce this problem?

#6

eMPee584 - September 13, 2008 - 10:46

remove an assigned action handling function of your choice from the corresponding actions_info.. then try to unassign it.

#7

Dave Reid - September 13, 2008 - 14:30
Title:actions that no longer exist can not be removed» Assigned actions that no longer exists still fire and can not be removed
Status:postponed (maintainer needs more info)» active

Ok I could confirm this. You need a module that provides a function via hook_action_info() that you can disable or uninstall.

1. Assign the module's action to a trigger.
2. Disable the module.
3. Confirm the action is still listed assigned to a trigger in admin/build/trigger.
4. Perform the trigger that would fire the action (should result in a function doesn't exists error)
5. Go to admin/build/trigger and attempt to unassign the action from the trigger
6. Confirm that the action is not removed (should also result in some undefined index notices)

Attached is a patch that performs a check to drupal_function_exists() for the action function and also allows for actions that no longer exist to be unassigned.
I've also attached the simple little module I used to test this.

AttachmentSizeStatusTest resultOperations
306540.unassign_action.patch2.35 KBIdleFailed: Failed to apply patch.View details | Re-test
action_test.zip849 bytesIgnoredNoneNone

#8

Dave Reid - September 13, 2008 - 14:31
Title:Assigned actions that no longer exists still fire and can not be removed» Assigned actions that no longer exist still fire and can not be removed
Assigned to:Anonymous» Dave Reid
Status:active» needs review

Patch needs review.

#9

Dave Reid - September 15, 2008 - 08:16
Title:Assigned actions that no longer exist still fire and can not be removed» Orphaned assigned actions still triggered and cannot be removed

Latest patch ready for testing and a summary of changes:
1. Fixed the incorrect link to 'admin/build/actions/orphan' to the correct url 'admin/settings/actions/orphan'
2. If an action is orphaned and no longer available (through say, a module disabled) and the current user has the permission 'administer actions', then a message is displayed about the orphaned action with a link to the url in the point above. This message will also be seen for orphaned actions on the admin/build/triggers or admin/settings/actions page.
3. If an action is orphaned but still assigned to a trigger, it can be successfully unassigned using the 'unassign' link in the action's trigger. Previous behavior: E_ALL notice errors during unassignment and action is never really unassigned.
4. If an action is orphaned and it is assigned to a trigger that occurs, you are going to get a fatal function not found error. When an action is called, it now checks to make sure that the action callback exists using drupal_function_exists.
5. Removed the $actions_in_code parameter from actions_synchronize because in every instance but one that the function is called, it is simply called as actions_synchronize(actions_list()). There is no point in having that parameter especially since the whole point is to re-synchronize the actions between what is available between module code and the actions database.

Ran the triggers and actions configuration test with 100% pass. Ready for review. Anyone?

AttachmentSizeStatusTest resultOperations
306540.orphaned_actions.patch6.07 KBIdleFailed: Failed to apply patch.View details | Re-test

#10

Dave Reid - September 15, 2008 - 14:24

Clarification about change 5 in #9 above:
I removed the $actions_in_code parameter and changed the first line of the actions_synchronize function to: $actions_in_code = array_list(TRUE);. Nearly every time the actions_synchronize function was called it was passed array_list() for the $actions_in_code parameter anyway. It seems logical and makes sense for "synchronize" function to always get a fresh list of the available actions.

#11

Dave Reid - September 15, 2008 - 14:50
Priority:normal» critical

I'm bumping this to critical since an orphaned action can still be executed, causing site failures, and cannot even be removed through the trigger interface.

#12

Dave Reid - September 15, 2008 - 16:53

Re-rolled to account for changes from #308526: Actions do not reset on sync.

AttachmentSizeStatusTest resultOperations
306540.orphaned_actions.patch6.07 KBIdleFailed: Failed to apply patch.View details | Re-test

#13

jvandyk - September 16, 2008 - 16:03

I have looked through this patch and made a few changes. The patch introduced a drupal_set_message() into actions.inc. Since actions.inc is intended as a pure api file, I moved the drupal_set_message() into the calling code. I support the proposed removal of the first parameter of actions_synchronize(). This patch also adds a drupal_set_message() so that the user gets feedback when they actually click on the "Remove orphaned actions" link; formerly a message was written to watchdog to indicate that the orphaned actions had been deleted but there was no feedback to the user; they were left blinking at the Actions setting page with no feedback.

AttachmentSizeStatusTest resultOperations
306540jv.patch7.86 KBIdleFailed: Failed to apply patch.View details | Re-test

#14

Dave Reid - September 16, 2008 - 18:10

I like your improvements jvandyk, but I had a couple of concerns:
1. I agree about moving the orphaned actions message out of actions.inc, but that message also needs to get displayed on admin/settings/actions, so I added the code to system_actions_manage().
2. Removed the check for user_access('adminster actions') in trigger_assign() since the triggers page requires the 'administer actions' permission anyway. (see trigger_menu and trigger_access_check().
3. Thanks for the additions to documentation - I missed those!
4. Removed the orphaned core function system_action_delete_orphans_post() since it seemed silly not to just display the 'action x deleted' message in system_actions_remove_orphans(). The function system_action_delete_orphans_post() is not called by anything else in core - it would be best to get rid of it.

I'm posting this for review, and now I'm going to go write a test for orphaned actions.

AttachmentSizeStatusTest resultOperations
306540.orphaned_actions.patch8.79 KBIdleFailed: Failed to apply patch.View details | Re-test

#15

jvandyk - September 17, 2008 - 13:45

Good changes. The patch works as expected.

#16

eMPee584 - September 18, 2008 - 23:02

mmh yeah seems to work although it's a good bit larger than my patch and does not apply cleanly to D6. Also, the call to actions_synchronize in system_actions_remove_orphans is seemingly missing the first parameter..

#17

Dave Reid - September 18, 2008 - 23:10

eMPee584, thanks to your original patch, we're able to make some much needed improvements with regards to orphaned actions such as warning the user when there are orphaned actions and not running an action function if it doesn't exist. Also, see change 5 in comment #9 with regards to the actions_synchronize parameter.

#18

eMPee584 - September 19, 2008 - 00:29

ah ok skipped over that note thx for pointing it out.. now anyways i removed the actions i was stuck with myyyyyy11 patch (prrrrrrreecious....) so i stand alone in my glory - however it gets committed, if it works it's good ;=)

#19

Dave Reid - October 10, 2008 - 15:32
Status:needs review» needs work

I've been working on splitting my large patch into smaller ones. Working on another revision.

#20

briskday - October 22, 2008 - 22:03
Version:7.x-dev» 6.5

#21

Dave Reid - October 22, 2008 - 22:09
Version:6.5» 7.x-dev

Please don't change the version. This needs to get fixed and accepted into 7.x first, then we can backport.

#22

cwgordon7 - November 10, 2008 - 03:07

@#19) Any progress with that? If not, I'd be happy to split this up into bug fixing vs API change patches, just let me know.

#23

Dave Reid - January 6, 2009 - 21:40

#24

Dave Reid - January 17, 2009 - 06:54
Issue tags:+actions

#25

threexk - May 22, 2009 - 15:39

In Drupal 6.12 I get the log message

One orphaned action (comment_unpublish_action) exists in the actions table. Remove orphaned actions

whenever I disable or enable the PHP filter module. Is this the same issue? I have not done anything with actions on my site.

#26

lilou - May 22, 2009 - 15:49

Same message on D7 fresh install.

#27

threexk - May 22, 2009 - 19:02

lilou: I'm assuming you're saying that with 7.x you're getting the same message I am. Does this Drupal issue pertain to that message? Does the patch from previous comments remove the message for you in 7.x?

#28

morningtime - August 5, 2009 - 16:17

I have this message "2 orphaned actions (views_bulk_operations_ruleset_action_rules_set_1, workflow_select_next_state_action) exist in the actions table. Remove orphaned actions". But both those actions do not exist in the actions table. Where to look now? How to remove them, from where?

#29

cwgordon7 - August 21, 2009 - 22:59
Status:needs work» needs review

I'd like to see if the test bot likes this.

#30

System Message - August 21, 2009 - 23:05
Status:needs review» needs work

The last submitted patch failed testing.

 
 

Drupal is a registered trademark of Dries Buytaert.