More elegant handling of recursion

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2017-03-19 22:09:47 +01:00
parent df14684817
commit 246e9ce547
No known key found for this signature in database
GPG Key ID: F941078878347C0C
2 changed files with 8 additions and 4 deletions

View File

@ -559,13 +559,17 @@ class DIContainer extends SimpleContainer implements IAppContainer {
});
}
public function query($name, $checkServerContainer = true) {
public function query($name) {
$name = $this->sanitizeName($name);
try {
return parent::query($name);
} catch (QueryException $e) {
if ($checkServerContainer === false) {
throw $e;
if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) {
$segments = explode('\\', $name);
if (strtolower($segments[1]) === strtolower($this['AppName'])) {
throw new QueryException();
}
}
}

View File

@ -79,7 +79,7 @@ class ServerContainer extends SimpleContainer {
$segments = explode('\\', $name);
$appContainer = $this->getAppContainer(strtolower($segments[1]));
try {
return $appContainer->query($name, false);
return $appContainer->query($name);
} catch (QueryException $e) {
// Didn't find the service in the respective app container,
// ignore it and fall back to the core container.