Problem/Motivation

The only place where vocabulary weight were used is sorting terms in term reference field #7684: Order taxonomy terms by vocabulary weight, then term weight
While vocabularies were converted to config entities we removed this ability with follow-up #1821274: Add back ability to sort on vocabulary weight and name
This feature was requested only once in #2969183: Vocabulary weight not honoured by Entity Reference fields

Proposed resolution

Deprecate this property and remove its usage
The only usage is VocabularyListBuilder which will needs to stop extends DraggableListBuilder - this may affect BC policy and, probably, some contrib

Remaining tasks

- discuss deprecation (actually list builder and tests)
- create change record and patch
- commit

User interface changes

- vocabularies no longer sorted at admin/structure/taxonomy

API changes

- VocabularyListBuilder extends ConfigEntityListBuilder instead of DraggableListBuilder

Data model changes

taxonomy_vocabulary config no longer export weight property

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost created an issue. See original summary.

mattjones86’s picture

I have to say I'm not a great fan of removing this feature. I can think of at least 3 Drupal (7/8) projects I've done in the last few years which have relied on this to sort vocabularies in custom filter blocks etc.

I can't be the only developer in the world who uses it, and I expect most who do will be doing something custom with \Drupal::entityQuery() where it works, and will not necessarily notice the ongoing bugs/issues with views/entityreference.

If it's decided that it's really not needed then I guess it's fine to depreciate for 8.x it and flag for removal in 9.x, however I still believe the more sensible approach is just to fix the bugs with the existing implementation.

andypost’s picture

@mattjones86 please elaborate how you did use weight, specifically in d8. It is totally not clear how weight of vocabulary related to blocks

mattjones86’s picture

Hi @andypost,

We've used it to allow customers to change the order of their filters as below:

Filtering

Using the drag/drop feature of the core vocabularies is much more convenient than implementing something custom.

Chi’s picture

@mattjones86, your case is valid but too specific. The filter on the screenshot is made with custom code, I suppose. From this point we should also add weight property to content types because it may have the same use case.

Out of box this property is not used in Drupal 8 and that makes the draggable inteface on admin/structure/taxonomy page confusing.

Even resolving #2969183: Vocabulary weight not honoured by Entity Reference fields will make a little difference. Implementing draggable interface just to specify order of vocabularies on field settings form seems redundant to me.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andypost’s picture

Assigned: Unassigned » andypost
mmenavas’s picture

FileSize
53.31 KB

I stumbled upon this discussion because I was looking for a way to programmatically get the weight property for my vocabularies.

My use case is similar to @mattjones86. I'm building a site with a search page that has several filters, where each filter corresponds to a vocabulary.

Filters

I understand that one of the arguments for removing the weight property is that Drupal core does not use it anywhere. However, that feature has been around since Drupal 5 (according to https://www.drupal.org/docs/7/organizing-content-with-taxonomies/create-...), and there might be more developers (like mattjones86 and me) who need this feature but aren't voicing their opinion because they don't know this discussion is happening.

@Chi wrote on comment #5:

@mattjones86, your case is valid but too specific. The filter on the screenshot is made with custom code, I suppose. From this point we should also add weight property to content types because it may have the same use case.

Not necessarily! AFAIK Drupal never offered a weight property for content types, and I'm not aware of any feature requests that ask for it.

andypost’s picture

Both cases are about filters so I see it like
- case of views exposed filters - order defined in view
- case facets - ordering by block placement or by facet's weight #2957950: Add views area plugin

andypost’s picture

Status: Active » Needs review
FileSize
1.34 KB

Starting patch to get number of usage

Status: Needs review » Needs work

The last submitted patch, 10: 3008064-10.patch, failed testing. View results

mattjones86’s picture

@andypost thanks for your feedback on this.

I don't believe either of the replacements you've suggested are suitable for site editors - for developers perhaps. In my opinion the only suitable replacement would be to use the Entityqueue module to allow the vocabulary list to be sorted with drag+drop.

This would provide the a similar editing experience (although somewhat clunkier) at the cost of quite a bit of performance and development overhead.

My 2p is that I really don't understand the rationale for removing a core feature which has very little support requirements from Drupal's side. If it was causing problems in other parts of the code or lots of support tickets then I could totally understand.

Also the agument that "'Content Types' don't support this" is not really valid, since the Taxonomy and Node modules were build to solve totally different problems and have very different requirements.

This is going to cause real problems for me and block me upgrading sites to Drupal 9, I'd be very surprised if I'm the only one!

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

MULK’s picture

Hi everybody!
I have the problem because the same case as @mattjones86 here. Filters order.

andypost’s picture

smustgrave’s picture

Will this need a deprecation test?

Status: Needs review » Needs work

The last submitted patch, 21: 3008064-21.patch, failed testing. View results

andypost’s picture

Assigned: andypost » Unassigned
Issue tags: +Needs upgrade path

I still think we can deprecate it

Maybe we need UX team as well

andypost’s picture

Probably we still need to solve sorting of filters via #1821274: Add back ability to sort on vocabulary weight and name but second related could be closed - no reason to extend interface

mattjones86’s picture

I still think you're going to be unpleasantly surprised how many developers were quietly using this without ever stumbling across this issue or having any input on the discussion.

For me personally (a single isolated developer), this will probably be adding £1000 to the next core upgrade to cover developing a custom solution to replace what was previously a core feature.

Hopefully someone will just re-implement this in contrib quickly.

Kingdutch’s picture

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Wim Leers’s picture

Note that #3008064: Deprecate vocabulary weight property is marking this fully validatable, and is adding the following changes wrt weight's config schema:

     weight:
+      # @todo Deprecate in https://www.drupal.org/project/drupal/issues/3008064
       type: integer
       label: 'Weight'
+      # A weight can be any integer, positive or negative.
+      constraints:
+        NotNull: []

👆 That amounts to no changes at all: it just means that any integer is accepted. It also means that it should remain trivial for this issue to deprecate weight 👍

Wim Leers’s picture

#29: that @todo should be converted to a follow-up issue that will remove it if #2002174: Allow vocabularies to be validated via the API, not just during form submissions lands first.

catch’s picture

I'm not convinced this is worth removing and lean towards doing #1821274: Add back ability to sort on vocabulary weight and name instead. The big difference between taxonomy vocabularies and content types is they're much more often exposed or combined into a single list etc.

Wim Leers’s picture

Status: Needs work » Closed (works as designed)

That means we should mark this Closed (works as designed) and leave a comment on #1821274: Add back ability to sort on vocabulary weight and name. #2, #8 and others indeed suggest this is actively being used.

Done.