I'm trying to implement hook_nodequeue_remove to prevent a queue going down to zero.

function mymodule_nodequeue_remove($sqid, $nid) {
  $subqueue = nodequeue_load_subqueue($sqid, TRUE);
  dsm($subqueue);
  if ($subqueue->count == 0) {
    dsm('EMPTY!!!!');
  }

This code doesn't work.

When I remove the last node in nodequeue admin, the count is given as 1. When I remove the last node on the node's nodequeue tab, the count is given as 0. Hence I can't reliably test whether the node being removed is the final one.

(I've tried the patch at #959450: hook_nodequeue_remove gets called twice when a node is removed from a subqueue., which has no effect on this bug.)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Fixed » Closed (fixed)

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

joachim’s picture

Version: 6.x-2.9 » 6.x-2.x-dev
Status: Closed (fixed) » Active

This is still a problem.

If I remove more than one node in the queue admin page, then only the last one gets the hook invoked:

  foreach ($nodes as $pos => $node) {
    if (!is_numeric($node['nid']) || $node['nid'] < 1) {
      return array(NODEQUEUE_INVALID_NID, 'Invalid nid value. New subqueue order not saved.');
    }
    if (is_numeric($pos)) {
      $clean[$count] = $node;
      $count++;
    }
    else if ($pos == 'r') {
      // !! there is only ever one node under the array key 'r' even if more than one were removed!
  
      // Remove the node from this subqueue.
      nodequeue_subqueue_remove_node($sqid, $node['nid']);
    }
    else {
      return array(NODEQUEUE_INVALID_POSITION, 'Invalid position value. New subqueue order not saved.');
    }
  }
joachim’s picture

Status: Active » Closed (fixed)

Actually, filing this problem as a new bug as it impacts other things and it's to do with the whole form rather than just this piece of code: http://drupal.org/node/1212896