Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions lib/private/ServerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class ServerContainer extends SimpleContainer {
/** @var DIContainer[] */
protected $appContainers;

/** @var string[] */
protected $hasNoAppContainer;

/** @var string[] */
protected $namespaces;

Expand All @@ -47,6 +50,7 @@ public function __construct() {
parent::__construct();
$this->appContainers = [];
$this->namespaces = [];
$this->hasNoAppContainer = [];
}

/**
Expand All @@ -69,15 +73,27 @@ public function registerAppContainer($appName, DIContainer $container) {

/**
* @param string $namespace
* @param string $sensitiveNamespace
* @return DIContainer
* @throws QueryException
*/
protected function getAppContainer($namespace) {
protected function getAppContainer($namespace, $sensitiveNamespace) {
if (isset($this->appContainers[$namespace])) {
return $this->appContainers[$namespace];
}

if (isset($this->namespaces[$namespace])) {
if (!isset($this->hasNoAppContainer[$namespace])) {
$applicationClassName = 'OCA\\' . $sensitiveNamespace . '\\AppInfo\\Application';
if (class_exists($applicationClassName)) {
new $applicationClassName();
if (isset($this->appContainers[$namespace])) {
return $this->appContainers[$namespace];
}
}
$this->hasNoAppContainer[$namespace] = true;
}

return new DIContainer($this->namespaces[$namespace]);
}
throw new QueryException();
Expand All @@ -96,7 +112,7 @@ public function query($name) {
if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) {
$segments = explode('\\', $name);
try {
$appContainer = $this->getAppContainer(strtolower($segments[1]));
$appContainer = $this->getAppContainer(strtolower($segments[1]), $segments[1]);
return $appContainer->queryNoFallback($name);
} catch (QueryException $e) {
// Didn't find the service or the respective app container,
Expand Down