Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Check this result generated by content_handler_field_multiple.inc when you have a multiple nodereference field with:
Group multiple values: yes
Show value(s) 2 starting from 0, NOT Reversed (start from last values)
You expect those two values, starting from first, then second, right? Now check the result. Starting from second, then first!
mysql> SELECT vid AS _vid, delta as _delta, nid AS _nid, field_programs_nid AS nid FROM content_field_programs WHERE vid IN (1216) ORDER BY nid ASC delta ASC;
+------+--------+------+------+
| _vid | _delta | _nid | nid |
+------+--------+------+------+
| 1216 | 0 | 1216 | 4896 |
| 1216 | 1 | 1216 | 4848 |
+------+--------+------+------+
2 rows in set (0.00 sec)
I don't really understand the need for "ORDER BY nid ASC" there, the code below doesn't give me any reason it's required. The only thing happening is:
$this->field_values[$vid][$delta] = $item;
Attaching a patch, removing that ORDER.
Comment | File | Size | Author |
---|---|---|---|
#3 | content_view_multiple-515984-3.patch | 1.03 KB | markus_petrux |
cck_multiple_order_bug.patch | 1.05 KB | meba |
Comments
Comment #1
yched CreditAttribution: yched commentedSorry, I don't get what is wrong in the example you provide.
+ what would be the buggy effect this causes on dislayed views ?
Comment #2
meba CreditAttribution: meba commentedLet's say you have nodereference field with two values:
Node1 title - which means delta of this value is 0
Node2 title - delta is 1
Because you have said that you want 2 values starting from one, in NORMAL order (not reversed), you expect to receive the titles in following order:
Node 1 title
Node 2 title
Now according to the SQL result, you have received:
Node 2 title (delta 1)
Node 1 title (delta 0)
The nodes are in wrong order. That's the problem.
Please note that this doesn't happen for non-nodereference fields
Comment #3
markus_petrux CreditAttribution: markus_petrux commentedI think the problem is that the alias for the nodereference field is "nid", and then the SQL engine is using that alias to resolve the ORDER BY expression.
Since the field alias can be used for ORDER BY expressions in MySQL and PostgreSQL, then the fix could be just use "_nid" and "_delta" for the first two columns in the ORDER BY clause.
Comment #4
markus_petrux CreditAttribution: markus_petrux commentedCommitted the patch in #3 to CVS (CCK2 and CCK3).