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.
Currently, the order of category->parents is broken during the node submit hook. I was looking into ways to fix this.
The attached patch provides a new utility function to sort a parent list, and uses it near the top of category_submit().
The function has a side effect of removing duplicate cids.
Comment | File | Size | Author |
---|---|---|---|
category-sort-before-save.patch | 2.18 KB | bdragon |
Comments
Comment #1
bdragon CreditAttribution: bdragon commentedReading this over, I realize that I should clarify the last part.
If a parent got listed multiple times (which can happen due to the way the parent selection forms operate), the returned array will still only list it once.
In other words, this works as a possibly "better" version of my fix for the "category_hierarchy duplicate entry" problem. (patch on #0 from http://drupal.org/node/76921, patch on #2 of http://drupal.org/node/92818).
Comment #2
Jaza CreditAttribution: Jaza commented@bdragon: http://drupal.org/node/92818 has been committed. Is this patch really needed? If you still think it should be committed, then please report back on what specific improvements / bug fixes will result from it, and on what performance hit this patch will incur.
Comment #3
bdragon CreditAttribution: bdragon commentedOk, the point of this patch is to keep $node->parents and $node->parent properly sorted at all times.
This is more of a "test and see if it fixes any random problems you were having with X" patch than anything else...
I haven't found any specific bugs fixed by this, and I don't think this patch is commit-worthy (too slow), but it's worth keeping around for testing.
Setting the issue to postponed.
Comment #4
bdragon CreditAttribution: bdragon commentedWONTFIX, this is no longer relevant.