From ca0803f593da0f359327f9313cf3bda22ce20afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 26 Jun 2017 13:58:54 +0200 Subject: [PATCH] [stable10] use efficient startsWith implementation, don't check if key exists twice --- lib/private/AppFramework/Utility/SimpleContainer.php | 4 ++-- lib/private/ServerContainer.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index 0c1e93caa590..6d5f2bae0529 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -107,9 +107,9 @@ public function resolve($name) { */ public function query($name) { $name = $this->sanitizeName($name); - if ($this->offsetExists($name)) { + try { return $this->offsetGet($name); - } else { + } catch (\InvalidArgumentException $ex) { $object = $this->resolve($name); $this->registerService($name, function () use ($object) { return $object; diff --git a/lib/private/ServerContainer.php b/lib/private/ServerContainer.php index c4f95b6488a6..d685ade98380 100644 --- a/lib/private/ServerContainer.php +++ b/lib/private/ServerContainer.php @@ -73,7 +73,7 @@ public function query($name) { // In case the service starts with OCA\ we try to find the service in // the apps container first. - if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { + if (strrpos($name, 'OCA\\', -strlen($name)) !== false && substr_count($name, '\\') >= 2) { $segments = explode('\\', $name); $appContainer = $this->getAppContainer(strtolower($segments[1])); try {