Skip to content

Commit

Permalink
Change circular alias response to throw exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Jan 2, 2024
1 parent 2af7bf0 commit 721c4a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ protected function loadLanguageLocale($locale, $domain, $processAliases = false)
* @param array $breadcrumbs Previously-resolved aliases (to prevent infinite loops)
*
* @return ?string
* @throws \Exception
*/
protected function resolveAlias(
array $alias,
Expand All @@ -280,7 +281,7 @@ protected function resolveAlias(
// Circular alias infinite loop prevention:
$breadcrumbKey = "$domain::$key";
if (in_array($breadcrumbKey, $breadcrumbs)) {
return null;
throw new \Exception("Circular alias detected resolving $breadcrumbKey");
}
$breadcrumbs[] = $breadcrumbKey;
return $this->resolveAlias($this->aliases[$domain][$key], $domain, $locale, $breadcrumbs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,8 @@ public function testCircularAliasSafety(): void
realpath($this->getFixtureDir() . 'language/circularaliases'),
];
$loader = new ExtendedIni($pathStack, 'en');
$this->expectExceptionMessage("Circular alias detected resolving Domain::baz");
$result = $loader->load('en', null);
$this->assertEquals(
[
'foo' => 'bar',
],
(array)$result
);
}

/**
Expand Down

0 comments on commit 721c4a9

Please sign in to comment.