Created a simple nodequeue with the following parameters:

  • Queue size: 4
  • Reverse in admin view: Enabled

Added 4 different nodes into this nodequeue. Everything is ok at this step.
Next, trying to add the node that already exists in this nodequeue.

The following events take place:

  • node at first position is deleted
  • node which is currently being added, is stored twice into DB

All this is quite bad, because finally it results in currupted nodequeue, that contains only 3 nodes instead of 4 (the 1-st item is lost).

I have an idea about how to fix this: we need to deny addition of nodes that already exist in nodequeue.
In particular, in autocomplete select we should not display those nodes, that were already added into the nodequeue.

I made the following patch to accomplish this (need to add code to nodequeue_api_autocomplete() function):

  // Select nodes wich added to current nodequeue.
  $exclude = array();
  foreach (_nodequeue_dragdrop_get_nodes($queue, $subqueue) as $queue_node) {
    $exclude[] = $queue_node->nid;
  }
 
  // Add query condition with exclude nids if nodequeue not empty.
  if (count($exclude)) {
    array_unique($exclude);
    $query->condition('n.nid', $exclude, 'NOT IN');
  }

See attached file nodequeue_exclude_dublicates.patch

CommentFileSizeAuthor
nodequeue_exclude_dublicates.patch781 bytesviktor.boykiv

Comments

jiv_e_old’s picture

Same issues:
http://drupal.org/node/701636
http://drupal.org/node/1022998

I think this solution is not the best. If you would add nodes dynamically via code the problem would still appear. Conseptually it would be right to check for dublicates in nodequeue_subqueue_add function and return an error if needed.

Additionally we could filter out already included nodes from autocomplete field. But I think there's no need to do it.

The basic idea is the same as in http://drupal.org/node/1022998. I'll attach my patch there.

amateescu’s picture

Status: Active » Closed (duplicate)