Currently, actions (defined in database) are invoked as follows on lin 99 of actions.inc

  $result[$action_ids] = $function($object, $context, $a1, $a2);

This creates problems where a trigger/action may be defined in the database, but a module supporting the action $function is disabled, resulting in a showstopping fatal error, which you'd need to manually edit the database to fix. Bad news!

This can be prevented by using call_user_func() as we do in a number of other places:

      $result[$action_ids] = call_user_funct($function, $object, $context, $a1, $a2);

That will simply return FALSE if for some reason the action function is undefined. I can roll a patch against 6.x-dev if that helps.

Comments

damien tournoud’s picture

Version: 6.4 » 7.x-dev
Category: feature » bug
Priority: Normal » Critical

Bumped to D7. This will need to be wrapped into a function_exists for D6 and a drupal_function_exists for D7.

Bumped to critical because that's something that should have been converted when the registry patch landed in D7.

jbomb’s picture

Status: Active » Needs review
StatusFileSize
new710 bytes

attached is the requested patch from #1.

webchick’s picture

We should probably expand our tests to cover this case, no?

pp’s picture

Status: Needs review » Needs work

How do I reproduce the bug?

I think the patch is not good. I saw the actions.inc and found two place where problem presents the patch just resolve one.
85. and 100. line contains:
$result[$action_id] = $function($object, $context, $a1, $a2);

pp

sun’s picture

Title: Update actions.inc to use call_user_func() » Fatal error when trying to invoke non-existing action callbacks
Status: Needs work » Needs review
Issue tags: +actions, +API clean-up
StatusFileSize
new1.71 KB

Tagging.

Regarding tests, please see #582316: Add tests for actions. It makes no sense to hold off this patch, because we have no tests and especially no pattern for tests for actions yet.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
+++ includes/actions.inc	19 Sep 2009 21:10:47 -0000
@@ -77,8 +77,13 @@ function actions_do($action_ids, $object
+          $actions_result[$action_id] = FALSE;

The actions return NULL. So FALSE is a sign of an error. Thanks for explaining me this sun.
Thats also good for testing this functionality later.

dries’s picture

Issue tags: +Needs tests

Committed to CVS HEAD. Marking 'code needs work' because we need tests.

dries’s picture

Status: Reviewed & tested by the community » Needs work
dave reid’s picture

Issue tags: +Needs backport to D6

This also should be backported to D6.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new1.49 KB

updated patch.

Status: Needs review » Needs work

The last submitted patch failed testing.

dawehner’s picture

Version: 7.x-dev » 6.x-dev
Status: Needs work » Needs review
StatusFileSize
new1.72 KB

There seems to be a bug in git diff, the identation got lost.

andypost’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new2.59 KB

It works, also re-roll against current DRUPAL-6

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Great, committed, thanks.

andypost’s picture

There's a similar issue which proposes UI change to cleanup orphaned actions #306540: Orphaned assigned actions still triggered and cannot be removed

@Gábor could you comment: is this change possible?

Status: Fixed » Closed (fixed)
Issue tags: -Needs backport to D6, -Needs tests, -actions, -API clean-up

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