summaryrefslogtreecommitdiffstats
path: root/lib/private/AppFramework
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-05-30 14:20:15 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2019-06-04 15:13:32 +0200
commit357263a70bf56e351e0d292c6144f998dad7f079 (patch)
tree5bdf1458172cbefad7ccd90c173040d8965c6b6b /lib/private/AppFramework
parent05058b0135813c4bfc355486e04e2324e2244078 (diff)
downloadnextcloud-server-357263a70bf56e351e0d292c6144f998dad7f079.tar.gz
nextcloud-server-357263a70bf56e351e0d292c6144f998dad7f079.zip
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 <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/AppFramework')
-rw-r--r--lib/private/AppFramework/DependencyInjection/DIContainer.php9
-rw-r--r--lib/private/AppFramework/Utility/SimpleContainer.php14
2 files changed, 7 insertions, 16 deletions
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php
index a6a9b205747..6d337bb9327 100644
--- a/lib/private/AppFramework/DependencyInjection/DIContainer.php
+++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php
@@ -374,17 +374,12 @@ class DIContainer extends SimpleContainer implements IAppContainer {
});
}
- /**
- * @param string $name
- * @return mixed
- * @throws QueryException if the query could not be resolved
- */
- public function query($name) {
+ public function query(string $name, bool $autoload = true) {
try {
return $this->queryNoFallback($name);
} catch (QueryException $firstException) {
try {
- return $this->getServer()->query($name);
+ return $this->getServer()->query($name, $autoload);
} catch (QueryException $secondException) {
if ($firstException->getCode() === 1) {
throw $secondException;
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 . '!');
}
/**