Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We ran into this on Drupal.org when trying to use the action with Views bulk operations.
From https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...
If no save action is present, one will be added.
This is indeed how the action is handled. After the db_update("node")
runs, the node entities are saved, along with their unchanged published property.
Instead, I think it is best to work with this system, and set the published status on the entity and let the actions infrastructure take care of the rest. It is more simple code for Mollom.
Comment | File | Size | Author |
---|---|---|---|
#22 | 2590101.patch | 1.44 KB | drumm |
#16 | 2590101-16.diff | 1.47 KB | B_man |
#13 | 2590101.diff | 1.42 KB | drumm |
Comments
Comment #2
drummAttached is a patch to fix this.
Comment #4
drumm#2254871: Default action behaviors in getAccessMask() could be the root cause here.
Comment #5
drumm#2254871: Default action behaviors in getAccessMask() is definitely the root cause.
Comment #6
drummI realized this is only updating the
{node}.status
column, but not the{node_revision}.status
column.node_load()
gets the object's status from{node_revision}.status
, so the nodes were unpublished in listings, but not unpublished on the individual node pages. We didn't notice this until now because we usually delete the nodes shortly after.Comment #7
drummThe attached patch uses the action API's
'behavior' => array('changes_property')
to do the node save when the action is done.Comment #8
drummComment #13
drummI confirmed this works using /admin/content's core bulk operation, and double checked the Views Bulk Operations UI works as well.
This updates the test to do the node save, as actions-calling code is expected to do.
Comment #14
drummComment #15
drummComment #16
B_manUpdating this patch for Akismet.
Comment #17
drummComment #18
B_manBacked this patch out as it seem to break functionality on d.o.
Comment #19
drummYes, seems this is no longer needed.
Comment #20
drummTurns out we do need this #3069572: "Report node to Akismet as spam and unpublish" does not unpublish
Comment #21
drummComment #22
drummFresh port of #13 to the new project.
Comment #23
gisleJust unpublished a spam node using the "Report node to Akismet as spam and unpublish" menu item. It did unpublish the node with no extra step required.
Comment #24
apaderno