mirror of
https://github.com/nextcloud/server.git
synced 2026-06-19 13:39:40 -04:00
remove duplicate OCA query handling and add earlier short cirtcuit for when instances are already created
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
8f4a19ccab
commit
3f487633d5
1 changed files with 12 additions and 16 deletions
|
|
@ -119,26 +119,22 @@ class ServerContainer extends SimpleContainer {
|
|||
* @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get
|
||||
*/
|
||||
public function query(string $name, bool $autoload = true) {
|
||||
// short circuit if have a registered instance ourselves
|
||||
if (isset($this[$name])) {
|
||||
return $this[$name];
|
||||
}
|
||||
$name = $this->sanitizeName($name);
|
||||
|
||||
if (str_starts_with($name, 'OCA\\')) {
|
||||
// Skip server container query for app namespace classes
|
||||
// In case the service starts with OCA\ we try to find the service in
|
||||
// the apps container first.
|
||||
if (($appContainer = $this->getAppContainerForService($name)) !== null) {
|
||||
try {
|
||||
return parent::query($name, false);
|
||||
return $appContainer->queryNoFallback($name);
|
||||
} catch (QueryException $e) {
|
||||
// Continue with general autoloading then
|
||||
}
|
||||
// In case the service starts with OCA\ we try to find the service in
|
||||
// the apps container first.
|
||||
if (($appContainer = $this->getAppContainerForService($name)) !== null) {
|
||||
try {
|
||||
return $appContainer->queryNoFallback($name);
|
||||
} catch (QueryException $e) {
|
||||
// Didn't find the service or the respective app container
|
||||
// In this case the service won't be part of the core container,
|
||||
// so we can throw directly
|
||||
throw $e;
|
||||
}
|
||||
// Didn't find the service or the respective app container
|
||||
// In this case the service won't be part of the core container,
|
||||
// so we can throw directly
|
||||
throw $e;
|
||||
}
|
||||
} elseif (str_starts_with($name, 'OC\\Settings\\') && substr_count($name, '\\') >= 3) {
|
||||
$segments = explode('\\', $name);
|
||||
|
|
|
|||
Loading…
Reference in a new issue