Commit ab20bac8 authored by catch's avatar catch
Browse files

fix: #3567086 Alias case sensitivity after the removal of the preload cache

By: alexpott
By: berdir
(cherry picked from commit 5b6d9bfa)
parent 2be4f973
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ public function getPathByAlias($alias, $langcode = NULL) {

    // Look for path in storage.
    if ($path_alias = $this->pathAliasRepository->lookupByAlias($alias, $langcode)) {
      $this->lookupMap[$langcode][$path_alias['path']] = $alias;
      $this->lookupMap[$langcode][$path_alias['path']] = $path_alias['alias'];
      return $path_alias['path'];
    }

+5 −0
Original line number Diff line number Diff line
@@ -326,6 +326,11 @@ public function testLookupPath(): void {
    $this->assertEquals($path_alias->getAlias(), $aliasManager->getAliasByPath($path_alias->getPath()), 'Basic alias lookup works.');
    $this->assertEquals($path_alias->getPath(), $aliasManager->getPathByAlias($path_alias->getAlias()), 'Basic source lookup works.');

    // Ensure that path alias data is used.
    $path_alias = $this->createPathAlias('/user/2', '/bar');
    $this->assertEquals($path_alias->getPath(), $aliasManager->getPathByAlias(strtoupper($path_alias->getAlias())), 'Basic source lookup is case insensitive.');
    $this->assertEquals($path_alias->getAlias(), $aliasManager->getAliasByPath($path_alias->getPath()), 'Basic alias lookup returns the stored alias if getPathByAlias() is called with a case insensitive alias.');

    // Create a language specific alias for the default language (English).
    $path_alias = $this->createPathAlias('/user/1', '/users/Dries', 'en');

+2 −2
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ public function testGetPathByAliasMatch(): void {
    $this->aliasRepository->expects($this->once())
      ->method('lookupByAlias')
      ->with($alias, $language->getId())
      ->willReturn(['path' => $path]);
      ->willReturn(['path' => $path, 'alias' => $alias]);

    $this->assertEquals($path, $this->aliasManager->getPathByAlias($alias));
    // Call it twice to test the static cache.
@@ -139,7 +139,7 @@ public function testGetPathByAliasLangcode(): void {
    $this->aliasRepository->expects($this->once())
      ->method('lookupByAlias')
      ->with($alias, 'de')
      ->willReturn(['path' => $path]);
      ->willReturn(['path' => $path, 'alias' => $alias]);

    $this->assertEquals($path, $this->aliasManager->getPathByAlias($alias, 'de'));
    // Call it twice to test the static cache.