PathAliasManager could not find the alias by the internal path

Created on 2 August 2021, almost 3 years ago
Updated 24 January 2023, over 1 year ago

Problem/Motivation

After one of the nodes was deleted, in a custom rest resource I tried to get the alias of the node from PathAliasManager::getAliasByPath(), but it returns with the internal path. I'am sure that the alias of the node was available, so I tried to find out the cause of the error.

Proposed resolution

I have found the related code at line 224 in PathAliasManager.
It has to be replaced from:
$this->noAlias[$langcode] = array_flip(array_diff_key($this->preloadedPathLookups[$langcode], array_keys($this->lookupMap[$langcode])));
to:
$this->noAlias[$langcode] = array_flip(array_diff($this->preloadedPathLookups[$langcode], array_keys($this->lookupMap[$langcode])));
because the preloadedPathLookups is an indexed array what contains paths as values, but the lookupMap contains paths as keys, and the array_keys() converts it to values and the new keys will be indexes, therefore the array_diff_key() always returns with the last value(s) of the preloadedPathLookups instead of really missing alias(es).

Remaining tasks

πŸ› Bug report
Status

Fixed

Version

9.5

Component
PathΒ  β†’

Last updated 6 days ago

  • Maintained by
  • πŸ‡¬πŸ‡§United Kingdom @catch
Created by

πŸ‡­πŸ‡ΊHungary pauger

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