Closed (fixed)
Project:
Drupal core
Version:
11.2.x-dev
Component:
entity system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
5 Feb 2021 at 13:03 UTC
Updated:
14 Jul 2025 at 03:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
paulocsComment #3
paulocsI added a patch to sort the bundles. The patch contains the fix and the test cases.
I also changed the issue summary as it was referencing to the wrong issue.
Comment #4
juhog commentedRegarding #3:
This custom sort logic probably won't be suitable. I believe the sorting needs to be done using sort() method of the bundle entity type.
One idea suggested in the parent issue (here) was to use loadBundleDescriptions() also for sorting the bundles. I'll give that a go, patch coming up shortly.
Comment #5
juhog commentedThis patch implements the idea brought up by alexpott in the parent ticket comment #132.
One concern in my implementation: I'm assuming bundle entity types always extend ConfigEntityBase. So I didn't add an if-clause to check whether sort() is callable or not. But I'm not sure if that's the case.
---
I'd like to ask about the bundle information array though:
Is it mandatory to always use EntityTypeBundleInfo::getBundleInfo() to get the list of bundles?
Seems like addPage() code could be simpler if bundle information array was used only when there is no bundle entity type. That would probably break some backwards compatibility though. Before returning the results, the bundle information service allows modules to add/remove some bundles by triggering alter('entity_bundle_info'). So I suppose addPage() must keep using getBundleInfo() in all situations?
Comment #6
juhog commentedComment #11
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #12
ranjith_kumar_k_u commented#5 failed to apply on 10.1x
error: patch failed: core/modules/system/tests/src/Functional/Entity/EntityAddUITest.php:72
error: core/modules/system/tests/src/Functional/Entity/EntityAddUITest.php: patch does not apply
Comment #13
ranjith_kumar_k_u commentedComment #14
smustgrave commentedTried testing this without the patch by going to node/add
I updated the labels multiple times to change the order and each time the order updates correctly.
Not entirely clear what this could be fixing? Could someone elaborate please.
Comment #15
smustgrave commentedNothing the change actually on admin/structure/types screen.
Comment #16
catchI don't think the early return should have been changed here. If for some reason we need to sort in this case to, it might need to happen separately.
Comment #19
acbramley commentedThis will be required for #3346394: Replace BlockContentController::add with EntityController::addPage via the AdminHtmlRouteProvider route provider
Comment #21
smustgrave commentedRan the test-only job here https://git.drupalcode.org/issue/drupal-3196798/-/jobs/5609439 which gave
Awesome use of extending an existing test!
Fix to core/lib/Drupal/Core/Entity/Controller/EntityController.php seems pretty straight forward with the uasort. No objections
LGTM
Comment #24
larowlanCommitted to 11.x and backported to 11.2.x as there is minimal risk of disruption here.
Thanks folks