Hi,

I have somehow managed to add a ndoe twice to the same nodequeue. on the nodequeue page it is only seen once, but on the actual view, it is shown twice. Removing the item from the nodequeue removes it from the nodequeue page and one instance from the view,but not the other.

Any ideas?

CommentFileSizeAuthor
#27 basic.js_.hide_.txt1.24 KBezra-g

Comments

naheemsays’s picture

Title: Duplicate item in nodequeue » Cannot remove items from nodequeue

ok, it seems like I may have figured this out.

removing an item from a nodequeue is currently NOT deleting the row from the database table - it is just setting the sqid to 0.

On the nodequeue page, this items will not be shown, but in a view, it will be as that does not filter out those with an sqid = 0.

Leavign priority as normal, but I would say it is more than that as this bug removes a lot oft eh functionality of nodequeue.

ezra-g’s picture

Status: Active » Postponed (maintainer needs more info)

Thanks for your detailed report.

I'm unable to recreate this. Testing with user with "manipulate queues" permission and a standard single node queue, there is no duplicate entry in the database. It sounds like you're saying that sqid is getting set to 0 in nodqueue_nodes, correct?

Can anyone else recreate this issue?

naheemsays’s picture

yes - on the delete action, instead of removing the full record, just sqid seems to get set to 0, and nodequeue ignores the record. However, views does not.

(the user had both "manipulate queues" and "manipulate all queues" permission. )

ezra-g’s picture

Does it set the sqid of all nodes in the subqueue to 0, or just the node that was removed?

Are you using mysql?

Can you recreate this with a fresh Drupal install with the latest nodequeue RC?

naheemsays’s picture

Just the node to be deleted in mysql. I will test on a fresh install and give further results.

naheemsays’s picture

hm... not getting this on a clean install without other modules... could it be an issue with memory useage?

ezra-g’s picture

I'm not sure how memory usage would cause this to happen. The query for removing a node from a subqueue doesn't update the entry for the node being removed, it just deletes the entry from nodequeue_nodes. In #5, you used the word delete. Just to be clear, we're talking about removing nodes from a subqueue, not deleting nodes that are in a queue, right?

Do you have modules enabled on your problematic install that interact with nodequeue?

naheemsays’s picture

Just views.

I mean remove the item from the nodeqeue - specifically clicking the text "remove from x" which is set in the nodequeue settings page.

On the site with the problem (which incidentally is live - I do crazy things), it does not remove the entry from nodequeue_nodes, just sets the sqid = 0. This worked properly with rc1.

sorry about the confusing language.

ezra-g’s picture

Is this happening on a fresh install?

naheemsays’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

nope. I think it is no longer happening no the old install either. Either that, or the user with permissions is working around the issue.

ezra-g’s picture

Version: 6.x-2.0-rc2 » 5.x-2.2
Status: Closed (fixed) » Postponed (maintainer needs more info)

Marked #320315: Cannot cleanly remove node from queue as a duplicate of this issue. Please see that issue for more information.

At this point it would be great if someone who is experiencing this problem could provide:

1) the result of a debug_backtrace() from nodequeue_subqueue_remove_node() when removing a node from a queue results in its entry in nodequeue_nodes having an NID of 0

2) The results of the following query: "SELECT * FROM {nodequeue_nodes};"

ezra-g’s picture

If you're unwilling or unable to provide this information, I could help guide you through the steps necessary to procure it, or you could grant me database, command line and browser access to the Drupal installation where you are having this issue and I can look at it myself.

naheemsays’s picture

I can no longer reproduce this problem.

billybob4’s picture

Hi,

I don't really understand how to provide what you're asking for in #1.
If you can tell me how to do it I'll provide.

#2:
mysql> select * from nodequeue_nodes;
+-----+------+------+----------+------------+
| qid | sqid | nid | position | timestamp |
+-----+------+------+----------+------------+
| 1 | 1 | 21 | 9 | 1223838481 |
| 1 | 1 | 20 | 8 | 1223838481 |
| 1 | 1 | 17 | 7 | 1223838481 |
| 1 | 1 | 18 | 6 | 1223838481 |
| 1 | 1 | 19 | 5 | 1223838481 |
| 1 | 1 | 22 | 4 | 1223838481 |
| 1 | 1 | 23 | 3 | 1223838481 |
| 1 | 1 | 0 | 2 | 1223838481 |
| 3 | 3 | 0 | 1 | 1223833299 |
| 3 | 3 | 34 | 2 | 1223833687 |
| 2 | 2 | 0 | 1 | 1223424742 |
| 1 | 1 | 0 | 1 | 1223838481 |
+-----+------+------+----------+------------+
12 rows in set

ezra-g’s picture

Thanks for helping here!

In order to pursue this, please:

delete all entries from the nodequeue_nodes table where the sqid is 0.
"DELETE FROM {nodequeue_nodes} WHERE sqid = 0;"

Then try clicking an "add to queue" link. Check the nodequeue_nodes table again. Is a new entry created with a sqid of 0?

If not try manipulating a queue and using either the "move to front" or "move to back" buttons. Does this create a value with a sqid of 0?

Thanks!

ezra-g’s picture

To clarify, both users on this thread reported that it appears as though the invalid entries in nodequeue_nodes are being created when a node is removed. I suspect that these values may be getting created when nodes are moved or entered into a queue, since the removal of a node from a queue doesn't ever modify or create a sqid value.

(sorry about the mail spam)

billybob4’s picture

Sorry for the length of this post

None of my nodequeue_nodes records have sqid of 0. It is the nid value that has been set to 0.
Following are the results of a series of actions that might help.

before removing nodes:

mysql> select * from nodequeue_nodes;
+-----+------+------+----------+------------+
| qid | sqid | nid  | position | timestamp  |
+-----+------+------+----------+------------+
|   1 |    1 |   21 |        9 | 1223838481 |
|   1 |    1 |   20 |        8 | 1223838481 |
|   1 |    1 |   17 |        7 | 1223838481 |
|   1 |    1 |   18 |        6 | 1223838481 |
|   1 |    1 |   19 |        5 | 1223838481 |
|   1 |    1 |   22 |        4 | 1223838481 |
|   1 |    1 |   23 |        3 | 1223838481 |
|   1 |    1 |    0 |        2 | 1223838481 |
|   1 |    1 |    0 |        1 | 1223838481 |
+-----+------+------+----------+------------+
9 rows in set

remove nodes with nid of 0:

mysql> DELETE FROM nodequeue_nodes WHERE nid = 0;
Query OK, 2 rows affected

after removing nodes:

mysql> select * from nodequeue_nodes;                                                    +-----+------+------+----------+------------+
| qid | sqid | nid  | position | timestamp  |
+-----+------+------+----------+------------+
|   1 |    1 |   21 |        9 | 1223838481 |
|   1 |    1 |   20 |        8 | 1223838481 |
|   1 |    1 |   17 |        7 | 1223838481 |
|   1 |    1 |   18 |        6 | 1223838481 |
|   1 |    1 |   19 |        5 | 1223838481 |
|   1 |    1 |   22 |        4 | 1223838481 |
|   1 |    1 |   23 |        3 | 1223838481 |
+-----+------+------+----------+------------+
7 rows in set

after adding a new node (nid 32) to the queue:

mysql> select * from nodequeue_nodes;
+-----+------+------+----------+------------+
| qid | sqid | nid  | position | timestamp  |
+-----+------+------+----------+------------+
|   1 |    1 |   21 |        9 | 1223838481 |
|   1 |    1 |   20 |        8 | 1223838481 |
|   1 |    1 |   17 |        7 | 1223838481 |
|   1 |    1 |   18 |        6 | 1223838481 |
|   1 |    1 |   19 |        5 | 1223838481 |
|   1 |    1 |   22 |        4 | 1223838481 |
|   1 |    1 |   23 |        3 | 1223838481 |
|   1 |    1 |   32 |        8 | 1224035990 |
+-----+------+------+----------+------------+
8 rows in set

(8 nodes show up in site admin view (quid 1) - correct)

after moving new item to top of nodequeue:

mysql> select * from nodequeue_nodes;
+-----+------+------+----------+------------+
| qid | sqid | nid  | position | timestamp  |
+-----+------+------+----------+------------+
|   1 |    1 |   32 |        8 | 1224036217 |
|   1 |    1 |   21 |        7 | 1224036217 |
|   1 |    1 |   17 |        6 | 1224036217 |
|   1 |    1 |   18 |        5 | 1224036217 |
|   1 |    1 |   19 |        4 | 1224036217 |
|   1 |    1 |   22 |        3 | 1224036217 |
|   1 |    1 |   23 |        2 | 1224036217 |
|   1 |    1 |    0 |        1 | 1224036217 |
+-----+------+------+----------+------------+
8 rows in set

(only 7 nodes show up in site admin view and front end - 8th node now has an id of 0 after this nodequeue order change)

move a different node to top of nodequeue:

mysql> select * from nodequeue_nodes;
+-----+------+------+----------+------------+
| qid | sqid | nid  | position | timestamp  |
+-----+------+------+----------+------------+
|   1 |    1 |   17 |        8 | 1224036587 |
|   1 |    1 |   32 |        7 | 1224036587 |
|   1 |    1 |   21 |        6 | 1224036587 |
|   1 |    1 |   18 |        5 | 1224036587 |
|   1 |    1 |   19 |        4 | 1224036587 |
|   1 |    1 |   22 |        3 | 1224036587 |
|   1 |    1 |   23 |        2 | 1224036587 |
|   1 |    1 |    0 |        1 | 1224036587 |
+-----+------+------+----------+------------+
8 rows in set

(7 nodes show up in site admin view and front end - 8th node has an id of 0. No new record with a nid of 0 despite the second nodequeue order change)

after delete a node (nid 32) from the queue using site admin:

mysql> select * from nodequeue_nodes;
+-----+------+------+----------+------------+
| qid | sqid | nid  | position | timestamp  |
+-----+------+------+----------+------------+
|   1 |    1 |   17 |        7 | 1224037518 |
|   1 |    1 |   21 |        6 | 1224037518 |
|   1 |    1 |   18 |        5 | 1224037518 |
|   1 |    1 |   19 |        4 | 1224037518 |
|   1 |    1 |   22 |        3 | 1224037518 |
|   1 |    1 |   23 |        2 | 1224037518 |
|   1 |    1 |    0 |        1 | 1224037518 |
+-----+------+------+----------+------------+
7 rows in set

set record with nid 0 to correct nid (20)

mysql> UPDATE nodequeue_nodes SET nid='20' WHERE nid='0';
Query OK, 1 row affected (0.45 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from nodequeue_nodes;
+-----+------+------+----------+------------+
| qid | sqid | nid  | position | timestamp  |
+-----+------+------+----------+------------+
|   1 |    1 |   17 |        7 | 1224037518 |
|   1 |    1 |   21 |        6 | 1224037518 |
|   1 |    1 |   18 |        5 | 1224037518 |
|   1 |    1 |   19 |        4 | 1224037518 |
|   1 |    1 |   22 |        3 | 1224037518 |
|   1 |    1 |   23 |        2 | 1224037518 |
|   1 |    1 |   20 |        1 | 1224037518 |
+-----+------+------+----------+------------+
7 rows in set (3.41 sec)

Now its tidy with 7 nodes in 1 queue, each with a unique position, starting with 1

used site admin to move nid 19 up one place (I have reverse view selected btw):

mysql> select * from nodequeue_nodes;
+-----+------+------+----------+------------+
| qid | sqid | nid  | position | timestamp  |
+-----+------+------+----------+------------+
|   1 |    1 |   21 |        7 | 1224038559 |
|   1 |    1 |   19 |        6 | 1224038559 |
|   1 |    1 |   18 |        5 | 1224038559 |
|   1 |    1 |   22 |        4 | 1224038559 |
|   1 |    1 |   23 |        3 | 1224038559 |
|   1 |    1 |   20 |        2 | 1224038559 |
|   1 |    1 |   17 |        8 | 1224038559 |
|   1 |    1 |    0 |        1 | 1224038559 |
+-----+------+------+----------+------------+
8 rows in set (0.00 sec)

** where has this 8th record come from? it has a nid of 0 (so you are correct, is does happen on an order change)

ezra-g’s picture

Ok, great. Thanks for this troubleshooting :D!

I think we're close to targeting and solving the problem. I'll pursue this more -- Your troubleshooting steps and being able to see your whole nodequeue_nodes table will make it easier for me to create the conditions that result in this error.

billybob4’s picture

great stuff. let me know if I can help any further.

thanks

ezra-g’s picture

@nbz: Was the queue in question using the "Reverse in admin view" option?

ezra-g’s picture

Actually, it probably doesn't matter if you have reverse queues enabled. I've been squeezing this issue in between other things this week but I should have some more dedicated time to devote to it this weekend. In the meantime, I suspect the problem is related to line ~1105 in nodequeue_arrange_subqueue_form_submit, $args[] = $nids[$old_pos];

naheemsays’s picture

@nbz: Was the queue in question using the "Reverse in admin view" option?

Yes it was. I will try to reproduce/help out later today/tomorrow.

ezra-g’s picture

Do each of you/your clients have javascript enabled or disabled in the browser? This could be a related factor.

Again, I'll get at this in more depth this weekend.

naheemsays’s picture

enabled.

and I appreciate you looking into this. It is tricky.

billybob4’s picture

My queue was reversed view yes, and javascript has never been disabled

ezra-g’s picture

billybob4 reported that he is using firefox 2 on WinXP. nbz: what is your browser and OS?

ezra-g’s picture

Title: Cannot remove items from nodequeue » Custom Javascript: Cannot remove items from nodequeue
Category: bug » support
Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new1.24 KB

billybob4's problem was being caused by custom javascript in a custom theme. billybob4 gave me access to the machine where this problem was occurring. I added

drupal_set_message("order:". dprint_r($order, TRUE));
drupal_set_message("nids:". dprint_r($nids, TRUE));

in nodequeue.module around line 1098 (after

if ($queue->reverse xor $form_values['op'] == t('Reverse')) {
      $order = array_reverse($order);
    }

) in nodequeue_arrange_subqueue_form_submit.

With javascript enabled, after rearranging the queue and submitting the form, this would output two arrays of new and old queue position values and nids, like this:

      # order

      Array
      (
          [0] => 1
          [1] => 2
          [2] => 3
          [3] => 5
          [4] => 4
          [5] => 6
      )

      # nids

      Array
      (
          [6] => 5
          [5] => 14
          [4] => 11
          [3] => 7
          [2] => 12
          [1] => 8
      )
    

In this case, I saw

    
  
* order

  Array
  (
      [0] => function (val) {
      for (var i = 0; i < this.length; i++) {
          if (this[i] == val) {
              return true;
          }
      }
      return false;
  }
      [1] => 1
      [2] => 2
      [3] => 3
      [4] => 5
      [5] => 4
      [6] => 6
      [7] => 7
  )

* nids

  Array
  (
      [7] => 23
      [6] => 17
      [5] => 19
      [4] => 18
      [3] => 21
      [2] => 22
      [1] => 20
  )

indicating that javscript had been entered as a value in the order array. $order is taken from the form values, so the javascript in question resulted in javascript being injected into the form.

These arrays are used to determine values inserted in the nodequeue_nodes table.

I identified the suspected javascript file and renamed it from basic.js to basic.js.hide and after reloading the page, this error was eliminated.

nbz: are you using any custom javascript?

The javascript file implicated is attached to this issue for reference.

I performed this troubleshooting in Firefox 3 on Mac OS X 10.4.11 .

ezra-g’s picture

I'd like to hear from nbz, but it seems like the least that could be done here to improve the module would be to prevent these bad values from getting saved.

naheemsays’s picture

I was using Firefox 3 on Vista - How do I test this javascript stuff?

As for the theme - it has been customised from 4seasons, but contains to javascript in it - I removed the bits that were in the original theme as I did not need them.

I am testing all this on my test server right now, but cannot reproduce - I have also email another user who suffered from the same problem to she if she has better "luck" reproducing it - My previous work around was to simple tell her to not do things the way she was.

EDIT - just attempted various things on a live site and still could not break it. Grrr!

naheemsays’s picture

and the other user can no longer reproduce it either. Sorry.

ezra-g’s picture

Marking as fixed and opened a new task to prevent this from happening in the future #337834: Prevent bad data from being saved to nodequeue_nodes

ezra-g’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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