Reordering taxonomy terms after "Reset to alphabetical" yields incorrect results upon save

Created on 5 December 2017, over 6 years ago
Updated 25 August 2023, 10 months ago

Problem/Motivation

The Taxonomy Term List shows terms in unexpected order when re-ordering following a reset to alphabetical order.

Steps to reproduce

Scenario 1

  1. Do a standard install
  2. Log in as admin
  3. Add the following tags in this order: Bravo 1, Alpha 2, Delta 3, Charlie 4. (These are the terms the new tests use.)
  4. Navigate to the list of tags. You should see them ordered as: Alpha 2, Bravo 1, Charlie 4, Delta 3.
  5. Drag Charlie 4 up so it is the second term in the list and Save.
  6. The list of tags should be ordered as: Alpha 2, Charlie 4, Bravo 1, Delta 3.
  7. Click reset to alphabetical and confirm.
  8. The list of tags should be: Alpha 2, Bravo 1, Charlie 4, Delta 3.
  9. Drag Charlie 4 up so it is the second term in the list and Save.
  10. The list of tags is expected to be ordered as: Alpha 2, Charlie 4, Bravo 1, Delta 3... but they are not ordered as expected.

If you clear cache and refresh the page after step 8 above, then the ordering in the last step is as would be expected.

Scenario 2, steps to reproduce

  1. Clear cache
  2. Go to tags list, /admin/structure/taxonomy/manage/tags/overview
  3. Drag Charlie 4 up so it is the second term in the list and Save.
  4. The list of tags should be ordered as: Alpha 2, Charlie 4, Bravo 1, Delta 3.
  5. Click Show row weights and confirm that row weights are in order 0, 1, 2, 3 (without the patch, the order may be wrong and you may need to clear caches)
  6. Add a view of Tags taxonomy (create a page) -- Add field Term ID, Add field Weight, Sort by Weight (asc), Save
  7. Go to to view page that you just created, confirm terms are sorted by weight
  8. Go to tags list, /admin/structure/taxonomy/manage/tags/overview
  9. Click Reset to alpha and confirm.
  10. The list of tags should be: Alpha 2, Bravo 1, Charlie 4, Delta 3.
  11. Go to to view page, reload
  12. Confirm order did not update as expected (not alpha, still sorted by weight)

As in Scenario 1, clearing cache and refreshing the page will correctly display term weight as 0. For the view, terms will be ordered by TID as that is the fallback default sort for views. Scenario 2 is fixed with the addition of `Cache::invalidateTags($term_ids);` that was added in #63 🐛 Reordering taxonomy terms after "Reset to alphabetical" yields incorrect results upon save Needs work .

Proposed resolution

Clear cache as part of resetting to alphabetical order.

Currently there's a function that does a straight-up database query to update weights, with no caches being cleared or invalidated.

Remaining tasks

  1. /li>
  2. What cache tags are cleared when a taxonomy term save happens? And are we clearing those tags here? See #49 🐛 Reordering taxonomy terms after "Reset to alphabetical" yields incorrect results upon save Needs work
  3. Should we also invalidate the ENTITY_TYPE_list and ENTITY_TYPE_list:BUNDLE cache tags? See #76 🐛 Reordering taxonomy terms after "Reset to alphabetical" yields incorrect results upon save Needs work
  4. Is the extra Cache invalidation necessary or is the resetCache faulty? See duplicate ticket #44
  5. Review

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Taxonomy 

Last updated 4 days ago

  • Maintained by
  • 🇺🇸United States @xjm
  • 🇬🇧United Kingdom @catch
Created by

🇺🇸United States daveferrara1

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024