ConfigEntityListBuilder pointlessly sorts twice

Created on 25 January 2017, almost 8 years ago
Updated 31 January 2023, almost 2 years 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 3 days 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.71.5 2024