diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2017-03-17 14:25:35 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-03-21 08:52:17 +0100 |
commit | 886202123cdd10aeb94a72cdd02708724e56e3cc (patch) | |
tree | 2275e32dcf32caba0dd40c1e4d312d6d02665a18 /lib/private | |
parent | fd0e42e093a9cb32b9f2a4f07519a5263d2f7c49 (diff) | |
download | nextcloud-server-886202123cdd10aeb94a72cdd02708724e56e3cc.tar.gz nextcloud-server-886202123cdd10aeb94a72cdd02708724e56e3cc.zip |
Update query method for DIContainer
To align with https://github.com/nextcloud/server/issues/2043#issuecomment-287348294
This would mean that AppContainers only hold the AppSpecific services
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/AppFramework/DependencyInjection/DIContainer.php | 16 | ||||
-rw-r--r-- | lib/private/ServerContainer.php | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index f1c6b460a92..429aa66d88a 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -43,12 +43,11 @@ use OC\AppFramework\Middleware\OCSMiddleware; use OC\AppFramework\Middleware\Security\SecurityMiddleware; use OC\AppFramework\Middleware\SessionMiddleware; use OC\AppFramework\Utility\SimpleContainer; -use OC\AppFramework\Utility\TimeFactory; use OC\Core\Middleware\TwoFactorMiddleware; use OC\RichObjectStrings\Validator; -use OC\Security\Bruteforce\Throttler; use OCP\AppFramework\IApi; use OCP\AppFramework\IAppContainer; +use OCP\AppFramework\QueryException; use OCP\Federation\ICloudIdManager; use OCP\Files\IAppData; use OCP\Files\Mount\IMountManager; @@ -568,7 +567,16 @@ class DIContainer extends SimpleContainer implements IAppContainer { }); } - public function query($name) { - return parent::query($name); + public function query($name, $checkServerContainer = true) { + $name = $this->sanitizeName($name); + try { + return parent::query($name); + } catch (QueryException $e) { + if ($checkServerContainer === false) { + throw $e; + } + } + + return $this->getServer()->query($name); } } diff --git a/lib/private/ServerContainer.php b/lib/private/ServerContainer.php index df0293addf7..85229e364ad 100644 --- a/lib/private/ServerContainer.php +++ b/lib/private/ServerContainer.php @@ -79,7 +79,7 @@ class ServerContainer extends SimpleContainer { $segments = explode('\\', $name); $appContainer = $this->getAppContainer(strtolower($segments[1])); try { - return $appContainer->query($name); + return $appContainer->query($name, false); } catch (QueryException $e) { // Didn't find the service in the respective app container, // ignore it and fall back to the core container. |