To recreate the problem, follow these steps:

Create a page node.

Create an advanced action, Unpublish post containing keyword foo.

Enable trigger module.

Assign the action to Trigger: After saving an updated post.

Edit the page node to contain the word foo. Save the node.

Check the log. It will show that the action fired, so the node should be unpublished now but the node is still published.

The problem is that for actions that affect node properties (such as the published property) we detect that and add a "Save post" action automatically, but that isn't happening with advanced actions. Background: we do the detection because unless the op is presave, the node has already been saved so the change to the property will not persist unless we save the node again.

The save is not happening because actions_function_lookup() is returning the wrong database field for advanced actions. It is returning the aid when it should be returning the callback.

Unassign the action you assigned. Apply this patch. Assign the action like you did above. The "Save post" action will now be added automatically as it should be, and editing the node should result in the action firing and the change persisting.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

Seems like a worthy bug fix based on the description. Still a problem?

Anonymous’s picture

Status: Needs review » Needs work

The last submitted patch failed testing.

andypost’s picture

triggers now have 'changes property'

Is this still reproduced?

andypost’s picture

Confirm this bug! Its caused by that node already saved when property going to change.

Patch should be re-roller, I think we need separate functions that return function name and AID

PS: Referenced issue #585868: Triggers/actions need overhaul (part II) - Presave

andypost’s picture

This actions (for node and comment) works only in _presave hook because actual update was removed from them!

So I think it's better to limit them to presave hooks

andypost’s picture

Status: Needs work » Needs review
catch’s picture

Title: Node property changes by advanced actions do not persist » Node and comment property changes by advanced actions do not persist
Component: trigger.module » system.module
Priority: Normal » Major
Issue tags: +Needs tests
catch’s picture

Issue tags: +Needs backport to D6

.

klonos’s picture

catch’s picture

klonos’s picture

Title: Node and comment property changes by advanced actions do not persist » Node and comment property changes by advanced actions do not persist

...and the issue title had a 'duplicate' space ;)

catch’s picture

#5: 244093-unpublish-presave-d7.patch queued for re-testing.

catch’s picture

Version: 7.x-dev » 8.x-dev
Issue tags: +Needs backport to D7

Just in case this still applies.

catch’s picture

Status: Needs review » Reviewed & tested by the community

Limiting these to presave hooks looks great.

The Drupal 7 patch is going to need an upgrade path for trigger module - presumably triggers could be left in an invalid state.

It is also probably an API change for contrib modules like rules if they use these actions, but right now they don't work anyway.

I don't see a way to add tests for this since we're removing functionality that didn't work (and never did). However the D7 upgrade path could have tests added for that so leaving the tag.

Once this is committed to 8.x, it is going to be CNW for 7.x to add the updates, I don't think we need simultaneous patches/commits here but if we do please slap it back down.

sun’s picture

#5: 244093-unpublish-presave-d7.patch queued for re-testing.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

I'm not sure why we can't write some tests along the lines of the OP. I'm definitely not comfortable making arbitrary, potentially BC-breaking changes to this stuff without test coverage.

catch’s picture

Webchick, you can't write a test for the op because this removes the association between the unpublish comment action and the 'after saving an updated post' trigger altogether. If one doesn't already exist you could write a test for the same action and a different trigger but that is not testing for this bug. And yes it's bc breaking but these options are dead code, have been for 3-4 years and the patch just makes that official.

sun’s picture

Status: Needs work » Reviewed & tested by the community

I somewhat agree with @catch. The actions are altering the passed in $thing properties. When being invoked past save, they have no impact. No matter how hard you try (or test). Or in other words: There's no way to test an action that cannot work in the first place.

Inventing a testing mechanism for configurable actions sounds like a nice challenge for the future though. It's somewhat related to ->generatePermutations() that we introduced in D7, but if you thought that this was a multi-dimensional problem, then testing configurable actions is a multi-multi-dimensional problem. Yuck. ;)

catch’s picture

Title: Node and comment property changes by advanced actions do not persist » Comment actions are (still) completely broken and have broken tests too
Assigned: jvandyk » Unassigned
Status: Reviewed & tested by the community » Needs work

There is more background in #1008198: Many actions are completely broken.

But reading through that, and more importantly #974072: Comment publish / unpublish actions are broken I see that while the patch here is fine, we still have tests for different comment actions that are completely wrong in core and other broken comment actions, and the other issue was marked as duplicate (by me). fwiw that's exactly the kind of test that could be written to prove this bug was fixed, but would be completely meaningless.

So to fix the other bug too, we need to do similar for the other actions, and remove those completely misleading tests. I won't work on that, I regret ever looking at this rats nest.

catch’s picture

Title: Comment actions are (still) completely broken and have broken tests too » Node and comment actions are (still) completely broken and have broken tests too
catch’s picture

Priority: Major » Normal

Clearly no-one uses this otherwise there'd be more activity here, so downgrading this.

dixon_’s picture

Although this issue mostly concerns actions, anyone stumbling over this issue should be aware of #764558: Remove Trigger module from core, which is RTBC at this point.

realwahl’s picture

I'm still interested in a solution for D7. I'm trying to "Unpublish content containing keyword(s)", but the content is published regardless of it containing or not the banned keywords.
So, is there any patch/solution for D7?

star-szr’s picture

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

andypost’s picture

Version: 8.9.x-dev » 7.x-dev
Issue summary: View changes

There's no trigger module in core 8+