Skip to content

Commit

Permalink
More elegant handling of recursion
Browse files Browse the repository at this point in the history
Signed-off-by: Roeland Jago Douma <[email protected]>
  • Loading branch information
rullzer committed Mar 19, 2017
1 parent b81ffbf commit 1d5a897
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions lib/private/AppFramework/DependencyInjection/DIContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,17 @@ public function registerCapability($serviceName) {
});
}

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();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/private/ServerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function query($name) {
$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.
Expand Down

0 comments on commit 1d5a897

Please sign in to comment.