Download & Extend

adding the same node more than once to a queue causes bad behavior

Project:Nodequeue
Version:7.x-3.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

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

#1

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.

#2

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.

#3

@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 :).

#4

Status:active» needs work

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.

AttachmentSizeStatusTest resultOperations
593468-inprog.patch790 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 593468-inprog.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test

#5

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

AttachmentSizeStatusTest resultOperations
593468-inprog.patch6.05 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 593468-inprog_0.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test

#6

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.

#7

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.

#8

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.

#9

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?

#10

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.

#11

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

#12

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!

#13

#14

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

#15

just approached this bug, subscribing

#16

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

subscribe

#17

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

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

#18

@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?

#19

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

#20

Status:needs work» needs review

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.

AttachmentSizeStatusTest resultOperations
nodequeue-add_same_node-593468-20.patch6.37 KBIdlePASSED: [[SimpleTest]]: [MySQL] 0 pass(es).View details | Re-test

#21

Status:needs review» needs work

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

#22

Version:7.x-2.x-dev» 7.x-3.x-dev
Status:needs work» needs review

#23

#24

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