So - another bug trophy to cwgordon7: in his testing and my mentoring for this GHOP task: http://drupal.org/node/201139

neither trigger_nodeapi NOR actions_do takes $node by reference. Thus, the $node is not modified

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

Status: Active » Needs work
FileSize
716 bytes

starting patch

pwolanin’s picture

Status: Needs work » Needs review
FileSize
1.96 KB

oops- didn't get it all in the patch

Gábor Hojtsy’s picture

Status: Needs review » Needs work

- Why was $object optional for actions_do()? Isn't it used as optional somewhere?
- We don't shorten names like $taxo

pwolanin’s picture

Status: Needs work » Needs review
FileSize
1.98 KB

I don't see any place where $object is omitted in the call to actions_do(). However, we should get Eaton or someone else who knows this code well to take a look at this problem.

new patch - fixes taxo naming

jvandyk’s picture

$object is optional for actions_do() because there is no requirement that an action act on an object. If you had an action that empties a certain directory, for example, it has no need of any parameters. You would call it by

actions_do('empty_my_directory');

Gábor Hojtsy’s picture

Status: Needs review » Needs work

This pushes the patch back to the drawing board.

pwolanin’s picture

Status: Needs work » Needs review

@jvandyk - perhaps so, but then you can't pass be reference, AFAICT.

Since the actions module for Drupal 5 doesn't seem require PHP 5, how does it work?

jvandyk’s picture

Here are our choices:

1. Apply the patch in #4. Pro: triggers/actions now works in PHP 4. I tested on PHP 4.4.7. Con: because parameters passed by reference cannot have default values, calling actions_do() gets messier. In my example above, we would now have to include a second parameter to actions_do() because $object would no longer be optional.

actions_do('empty_my_directory', $dummy);

2. Actions and triggers are PHP5-only, since PHP5 uses implicit call-by-reference.

jvandyk’s picture

actions.module for Drupal 5 has a different architecture and does not apply here.

pwolanin’s picture

Well - unless the Drupal 6 requirements will be PHP 5+ only, I think we need to fix this even if the code is a little messier.

Gábor Hojtsy’s picture

Let's add some code comments on actions_do() then about this.

chx’s picture

http://buytaert.net/php-is-dead-long-live-php

PHP5's slow adoption rate is becoming annoying. So let us help the PHP project by giving Drupal users a compelling reason to upgrade to PHP5:

With every Drupal release, let us make some of the new (non-critical) features PHP5-only, and gradually drop support for PHP4.

We can easily wrap actions.inc include in a php version check and trigger.info could get a php = 5.0 line. Thoughts?

Gábor Hojtsy’s picture

chx: I don't think this quote from Dries maps to Drupal 6's action feature.

jvandyk’s picture

FileSize
3.18 KB

Patch with comments. Comment cleanup was necessary anyway because the comments still referenced the old-style function calls.

Gábor Hojtsy’s picture

Status: Needs review » Fixed

Thanks. As I have said, I don't think we should opt for a PHP 5 only feature here, so I committed what we can do for now. This is not looking ideal, so it give more fuel for the API cleanup that PHP 5 can get us in Drupal 7.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

pwolanin’s picture

Version: 6.x-dev » 7.x-dev
Status: Closed (fixed) » Needs review

this patch should probably be reversed for 7.x since it works for PHP 5.2

pwolanin’s picture

Priority: Critical » Normal
FileSize
2.06 KB

here's a patch that selectively reverts the code changed for PHP4 support (does not revert the comment cleanup, for example).

Dries’s picture

As Drupal 7 will be PHP5.2+ only, this patch no longer needs to be applied -- does it?

pwolanin’s picture

Title: $node not passed by reference - fails on PHP4.4 » remove PHP 4 compatibilty code from actions/triggers in 7.x

@Dries - the latest patch is to partially roll-back the patch applied to 6.x. We had to patch 6.x to add back PHP 4.4 compatibility. For 7.x, this is not needed, so the last patch would move 7.x back to using simpler/cleaner PHP 5.2-compatible code.

Updating the title to clarify.

Dries’s picture

Status: Needs review » Fixed

Ah, got it now. Thanks. Committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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