ConfigEntityListBuilder pointlessly sorts twice

Created on 25 January 2017, over 7 years ago
Updated 31 January 2023, over 1 year ago

ConfigEntityListBuilder::load() sorts the config entities using the entity class's sort() method:

    // Sort the entities using the entity class's sort() method.
    // See \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
    uasort($entities, array($this->entityType->getClass(), 'sort'));
    return $entities;

However, prior to that, the inherited method EntityListBuilder::getEntityIds() applies a sort:

  protected function getEntityIds() {
    $query = $this->getStorage()->getQuery()
      ->sort($this->entityType->getKey('id'));

The sorting here is thus redundant.

(Furthermore, config entity queries have their sort applied in PHP, not in SQL (since the entities properties are all serialized in the database -- see Drupal\Core\Config\Entity\Query\Query::execute()), so that's two lots of PHP sorting.)

The fix would be to override getEntityIds() in ConfigEntityListBuilder and remove the sorting.

πŸ“Œ Task
Status

Needs work

Version

10.1 ✨

Component
Configuration entityΒ  β†’

Last updated about 16 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom joachim

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

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