Just upgraded to 6.x-2.4 and noticed some strange behavior when you try to add the same node more than once to a queue.

What I see is that the node does get added again to the {nodequeue_nodes} table, but the interface (editing) screen (/admin/content/nodequeue/%nodequeue) only shows the node once. This then causes havoc when you try to remove and rearrange other nodes in the queue.

(Previously, nodequeue handled adding the same node to a queue more than once just fine.)

Comments

michaelsauter’s picture

Also, if you add the same node two (sometimes three) times to the end of the queue, it deletes the first item of the queue.

rokit88’s picture

Component: User interface » Code

I did a little further investigation and this problem has to do with the code that generates the editing interface. It's built from an array that is keyed by node id.

Therefore, if you have a given node in a queue more than once, that node will only be represented once on editing screen.

ezra-g’s picture

@rokit88 Thanks for pointing this out. I'd love to see this fixed, but don't anticipate correcting it myself before the next release. I would be happy to review a patch though :).

ezra-g’s picture

Status: Active » Needs work
StatusFileSize
new790 bytes

Here's a patch that shows the general kind of change that might bring this feature back/fix this bug. It's incomplete and needs some work.

This patch changes the form structure so that it can display the queue with multiple values, and does part of the work for interpreting these values from the form and passing them to nodequeue_save_subqueue_order.

The next step here is to make sure that the $form_state['values'] contain both the nid and position of nodes in the queue. With this patch, the position is described twice, but the nid is not. Therefore, it is impossible to save the subqueue order.

I've spent a good amount of time working on this. It would be great if someone who needs this feature could take this patch the rest of the way.

ezra-g’s picture

StatusFileSize
new6.05 KB

Sorry, that was somewhat hilariously not the right patch. It is now attached.

rokit88’s picture

Thanks! I've been away so I haven't gotten a chance to look at it, but I will check it out now and let you know my findings.

les lim’s picture

Version: 6.x-2.4 » 7.x-2.x-dev

FYI, this appears to be a blocker to #302671: Add to queue from Node edit form. The approach in #4 wouldn't resolve that issue, but whatever the outcome I think this issue will need to be resolved first.

les lim’s picture

FYI, I submitted a patch in #302671: Add to queue from Node edit form which contains a couple API changes for dealing with multiple appearances of a node in a queue. Not directly related to this particular issue, though.

marcvangend’s picture

I see that this issue is marked as 7.x-2.x-dev... is there any chance that it will be fixed for D6?
It isn't clear to me which patch is the best option right now. If I want to help out by testing a patch, which one should I use?

les lim’s picture

The patches above are all off the 6.x version, I believe. I think the 6.x-2.x-dev version got renamed to the 7.x-2.x-dev version and a new 6.x-2.x-dev was created in its place, which is why this is appearing as 7.x now.

marcvangend’s picture

@lesmana: thanks, I'll give the patch from #5 a try when I get back to work on monday.

fabianderijk’s picture

Hi,

I just tried this patch, and it works fine. When i add a node that has already been added it does show now in the queue (there is a drupal_set_message in the code that should be deleted though on line 2757).

But now when I try to change the order of the queue the order isn't saved.

If this could be solved this patch would be fine to use!

hermes_costell’s picture

Any news on this? Being able to properly manage a node being added multiple times to a queue in 6.x would be sweet.

aleksey.tk’s picture

just approached this bug, subscribing

bzbzh’s picture

Version: 7.x-2.x-dev » 6.x-2.11

subscribe

amateescu’s picture

Version: 6.x-2.11 » 7.x-2.x-dev
Assigned: amateescu » Unassigned

@bzbz, haven't you seen the news? http://drupal.org/node/1306444

bzbzh’s picture

@amateescu, I hadn't. thx.

Yet the aim of my post was to say: I still have this issue with latest (not dev) version of the 6.x module.

That why I changed it to 6.x-2.11. Was it wrong too?

amateescu’s picture

@bzbz, well, we generally fix bugs in the latest release and then backport them, it's the Drupal core development model :)

jojonaloha’s picture

Status: Needs work » Needs review
StatusFileSize
new6.37 KB

I ran into this recently using 7.x-2.0-beta1. While I wouldn't normally see why somebody would want to add two of the same node to a queue, this bug will not only show one instance of the node on the form, but if your queue is of fixed size and already full, the first node in the queue will be removed, reducing the size of the queue by 2.

In any case, I've attached a patch which goes off the 7.x-3.x branch, but I imagine it can be backported to 7.x-2.x fairly easily. The patch does include some changes that may or may not have been necessary, for instance in _nodequeue_dragdrop_get_nodes(), it was doing a leftJoin instead of an innerJoin, innerJoin's are typically much faster and should generally be used unless a leftJoin is needed to get the desired result, which didn't look like the case to me here.

Let me know if you need help backporting it, or if anything needs work.

Status: Needs review » Needs work

The last submitted patch, nodequeue-add_same_node-593468-20.patch, failed testing.

jojonaloha’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
Status: Needs work » Needs review
jojonaloha’s picture

hermes_costell’s picture

"While I wouldn't normally see why somebody would want to add two of the same node to a queue"
Example: advertising banners, where certain banners are given a higher rotation (are in the Nodequeue multiple times) than others. Etc.

spadxiii’s picture

Status: Needs review » Needs work

@jojonaloha
I just applied this to 7.x-2.0-beta1 and I've found a few issues:

  1. Removing items from the queue doesn't work anymore: the token is wrong. This is because your patch changes the generation of the token to use $key instead of $node->nid
     // Inside the function 'nodequeue_arrange_subqueue_form'
    nodequeue_get_query_string($key, TRUE), 
    // This should be
    nodequeue_get_query_string($node->nid, TRUE), 
    
  2. Removing always removes the top item, not the one clicked. This is the way the nodequeue handles the delete (it searches for the MIN(position) and removes that item). It would be great if your patch could fix this as well.

ps. for the most part, this patch applies to 7.x-2.0-beta1 just fine. There is only a single hunk that doesn't apply cleanly. (I've applied it by hand)

leksat’s picture

Version: 7.x-3.x-dev » 7.x-2.x-dev
Status: Needs work » Needs review
StatusFileSize
new6.31 KB

Attached patch from #20 with improvements from #25 adapted for 7.x-2.x branch.
It works for me as well (deleting also).

killua99’s picture

Ok the patch 20 it's for the 3.x branch right?

peter.milan’s picture

StatusFileSize
new6.31 KB

I found a bug in the #26 patch. Bug is present on click on remove link.

+    $form['nodes'][$key]['remove'] = array('#markup' => l(t('remove'), 'nodequeue/' . $queue->name . '/remove-node/' . $subqueue->sqid . '/' . $node->nid, $attr));

should be replaced with

+    $form['nodes'][$key]['remove'] = array('#markup' => l(t('remove'), 'nodequeue/' . $queue->qid . '/remove-node/' . $subqueue->sqid . '/' . $node->nid, $attr));
peter.milan’s picture

There is still bug if you add first element

Notice: Undefined index: nodes in nodequeue_arrange_subqueue_form_validate() (line 878 of /home/pity/workspace/welforum/sites/all/modules/contrib/nodequeue/includes/nodequeue.admin.inc).
Notice: Undefined index: nodes in nodequeue_arrange_subqueue_form_validate() (line 879 of /home/pity/workspace/welforum/sites/all/modules/contrib/nodequeue/includes/nodequeue.admin.inc).
Warning: Invalid argument supplied for foreach() in nodequeue_arrange_subqueue_form_validate() (line 879 of /home/pity/workspace/welforum/sites/all/modules/contrib/nodequeue/includes/nodequeue.admin.inc).

valgibson’s picture

Issue summary: View changes
Issue tags: +nodequeue
StatusFileSize
new881 bytes

Applied patch from #26 but also got removement bug. Changed this as described in #28. It works.

Status: Needs review » Needs work

The last submitted patch, 30: nodequeue-add_same_node-593468-30.patch, failed testing.

The last submitted patch, 30: nodequeue-add_same_node-593468-30.patch, failed testing.

killua99’s picture

valgibson you need to merge you patch with the #26 to test it ...

fizk’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -nodequeue
StatusFileSize
new6.34 KB

Rerolled for 7.x-2.x-dev. Works great for me.

  • fizk committed b2576a4 on 7.x-2.x
    Issue #593468 by ezra-g, jojonaloha, peter.milan, fizk, Leksat,...
fizk’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks everyone!

Status: Fixed » Needs work

The last submitted patch, 34: nodequeue-add_same_node-593468-34.patch, failed testing.

fizk’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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