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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drumm created an issue. See original summary.

drumm’s picture

Status: Active » Needs review
FileSize
592 bytes

Attached is a patch to fix this.

Status: Needs review » Needs work

The last submitted patch, 2: 2590101.diff, failed testing.

drumm’s picture

drumm’s picture

Status: Needs work » Closed (works as designed)
drumm’s picture

Status: Closed (works as designed) » Active

I 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.

drumm’s picture

The attached patch uses the action API's 'behavior' => array('changes_property') to do the node save when the action is done.

drumm’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 7: 2590101.diff, failed testing.

The last submitted patch, 7: 2590101.diff, failed testing.

The last submitted patch, 7: 2590101.diff, failed testing.

The last submitted patch, 7: 2590101.diff, failed testing.

drumm’s picture

I 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.

drumm’s picture

Assigned: drumm » Unassigned
drumm’s picture

Issue tags: -affects drupal.org
B_man’s picture

Project: Mollom » Akismet (Mollom replacement)
Version: 7.x-2.x-dev »
FileSize
1.47 KB

Updating this patch for Akismet.

drumm’s picture

Title: "Report node to Mollom as spam and unpublish" action should properly unpublish » "Report node to Akismet as spam and unpublish" action should properly unpublish
B_man’s picture

Backed this patch out as it seem to break functionality on d.o.

drumm’s picture

Status: Needs review » Closed (cannot reproduce)

Yes, seems this is no longer needed.

drumm’s picture

Assigned: Unassigned » drumm
Status: Closed (cannot reproduce) » Needs work
drumm’s picture

Project: Akismet (Mollom replacement) » Akismet
Version: » 7.x-2.x-dev
drumm’s picture

Status: Needs work » Needs review
FileSize
1.44 KB

Fresh port of #13 to the new project.

gisle’s picture

Status: Needs review » Reviewed & tested by the community

Just 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.

apaderno’s picture

Issue tags: +affects drupal.org