Do not load all the entities to check alias exist

Created on 26 August 2025, 7 days ago

Problem/Motivation

\Drupal\domain_unique_path_alias\DomainUniquePathAliasHelper::isExistingAlias Load all the entities only to check if there is a match or not. We can use a count query instead.

Steps to reproduce

Proposed resolution

Use a count query

  /**
   * Gets if the current alias exist.
   *
   * @return bool
   *   Boolean if alias exist.
   */
  public function isExistingAlias(string $alias): bool {
    return $this->entityTypeManager
      ->getStorage('path_alias')
      ->getQuery()
      ->accessCheck(FALSE)
      ->condition('alias', (array) $alias, 'IN')
      ->count()
      ->execute() > 0;
  }

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇫🇷France nod_ Lille

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

Comments & Activities

Production build 0.71.5 2024