Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293485

PathAliasManager could not find the alias by the internal path

$
0
0

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


Viewing all articles
Browse latest Browse all 293485

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>