Commit 37d3b425 authored by dalin's avatar dalin Committed by Berdir
Browse files

Issue #2950643 by dalin: Implementing hook_pathauto_pattern_alter() causes...

Issue #2950643 by dalin: Implementing hook_pathauto_pattern_alter() causes random incorrect paths when aliases are bulk (re)generated
parent 7a9da07a
......@@ -170,8 +170,9 @@ class PathautoGenerator implements PathautoGeneratorInterface {
'bundle' => $entity->bundle(),
'language' => &$langcode,
);
// @todo Is still hook still useful?
$pattern_original = $pattern->getPattern();
$this->moduleHandler->alter('pathauto_pattern', $pattern, $context);
$pattern_altered = $pattern->getPattern();
// Special handling when updating an item which is already aliased.
$existing_alias = NULL;
......@@ -241,7 +242,15 @@ class PathautoGenerator implements PathautoGeneratorInterface {
'language' => $langcode,
);
return $this->aliasStorageHelper->save($path, $existing_alias, $op);
$return = $this->aliasStorageHelper->save($path, $existing_alias, $op);
// Because there is no way to set an altered pattern to not be cached,
// change it back to the original value.
if ($pattern_altered !== $pattern_original) {
$pattern->setPattern($pattern_original);
}
return $return;
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment