Hi,

There's a problem with the way the unpublishing of nodes is done that leads to an unpublished node being shown as "Published" in the admin/content view when using revisions.

The problem is located line 1976 of antispam.module:

if ($content_type == 'node') {
    // This code snippet is based on node.module::node_admin_nodes_submit()
    // Only the node record is updated, no other hooks are invoked.

    // perform the update action.
    db_update('node')
      ->fields(array(
        'status' => ($op == 'publish'? 1:0)
      ))
      ->condition('nid', $content->nid)
      ->execute();

    [...]
  }

Only the node is updated, not the revisions. We need to also update the current revision like so:

    // perform the update action.
    db_update('node')
      ->fields(array(
        'status' => ($op == 'publish'? 1:0)
      ))
      ->condition('nid', $content->nid)
      ->execute();
    
    // perform the update action of the revision.
    db_update('node_revision')
      ->fields(array(
        'status' => ($op == 'publish'? 1:0)
      ))
      ->condition('nid', $content->nid)
      ->condition('vid', $content->vid)
      ->execute();

I'm attaching the patch file for those who want it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Growiel’s picture

Status: Needs review » Needs work

The last submitted patch, 1: antispam-unpublished_nodes-2194633-1.patch, failed testing.

Growiel’s picture

FileSize
998 bytes

New patch... (I patched from environement, not from a git clone of antispam so it failed)

Growiel’s picture

Status: Needs work » Needs review
DamienMcKenna’s picture

FileSize
1.14 KB

Rerolled, and fixed some small formatting mistakes.

DamienMcKenna’s picture

Status: Needs review » Fixed

Committed.

DamienMcKenna’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Fixed » Patch (to be ported)
Issue tags: +Needs backport to D6

Needs to be backportted to D6.

Growiel’s picture

Assigned: Growiel » Unassigned

I don't have or know D6, I unassigned from myself as I can't do the backport.

apaderno’s picture

Status: Patch (to be ported) » Closed (outdated)

I am closing this issue, since Drupal 4.x, 5.x, and 6.x are now not supported.