From 357263a70bf56e351e0d292c6144f998dad7f079 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 30 May 2019 14:20:15 +0200 Subject: Do not try to autoload built in types This avoids calls to the autoloader (or chain of autoloaders) to see if for example 'principalPrefix' class can be found. While we already know it is a string. Signed-off-by: Roeland Jago Douma --- lib/private/AppFramework/Utility/SimpleContainer.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'lib/private/AppFramework/Utility') diff --git a/lib/private/AppFramework/Utility/SimpleContainer.php b/lib/private/AppFramework/Utility/SimpleContainer.php index 6c2844e681b..6f50523bbf6 100644 --- a/lib/private/AppFramework/Utility/SimpleContainer.php +++ b/lib/private/AppFramework/Utility/SimpleContainer.php @@ -65,7 +65,8 @@ class SimpleContainer extends Container implements IContainer { } try { - $parameters[] = $this->query($resolveName); + $builtIn = $parameter->hasType() && $parameter->getType()->isBuiltin(); + $parameters[] = $this->query($resolveName, !$builtIn); } catch (QueryException $e) { // Service not found, use the default value when available if ($parameter->isDefaultValueAvailable()) { @@ -105,23 +106,18 @@ class SimpleContainer extends Container implements IContainer { } } - - /** - * @param string $name name of the service to query for - * @return mixed registered service for the given $name - * @throws QueryException if the query could not be resolved - */ - public function query($name) { + public function query(string $name, bool $autoload = true) { $name = $this->sanitizeName($name); if ($this->offsetExists($name)) { return $this->offsetGet($name); - } else { + } else if ($autoload) { $object = $this->resolve($name); $this->registerService($name, function () use ($object) { return $object; }); return $object; } + throw new QueryException('Could not resolve ' . $name . '!'); } /** -- cgit v1.2.3