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).