diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Diagnostics/Query.php | 13 | ||||
-rw-r--r-- | lib/private/Diagnostics/QueryLogger.php | 10 | ||||
-rw-r--r-- | lib/private/Files/Node/LazyRoot.php | 2 | ||||
-rw-r--r-- | lib/private/Server.php | 30 | ||||
-rw-r--r-- | lib/public/Diagnostics/IQuery.php | 12 |
5 files changed, 52 insertions, 15 deletions
diff --git a/lib/private/Diagnostics/Query.php b/lib/private/Diagnostics/Query.php index 908ad17f9db..8ac2cc0eeac 100644 --- a/lib/private/Diagnostics/Query.php +++ b/lib/private/Diagnostics/Query.php @@ -34,15 +34,18 @@ class Query implements IQuery { private $end; + private $stack; + /** * @param string $sql * @param array $params * @param int $start */ - public function __construct($sql, $params, $start) { + public function __construct($sql, $params, $start, array $stack) { $this->sql = $sql; $this->params = $params; $this->start = $start; + $this->stack = $stack; } public function end($time) { @@ -69,4 +72,12 @@ class Query implements IQuery { public function getDuration() { return $this->end - $this->start; } + + public function getStartTime() { + return $this->start; + } + + public function getStacktrace() { + return $this->stack; + } } diff --git a/lib/private/Diagnostics/QueryLogger.php b/lib/private/Diagnostics/QueryLogger.php index 5cf7e0689f8..a30f8c7b02a 100644 --- a/lib/private/Diagnostics/QueryLogger.php +++ b/lib/private/Diagnostics/QueryLogger.php @@ -42,7 +42,15 @@ class QueryLogger implements IQueryLogger { * @param array $types */ public function startQuery($sql, array $params = null, array $types = null) { - $this->activeQuery = new Query($sql, $params, microtime(true)); + $this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack()); + } + + private function getStack() { + $stack = debug_backtrace(); + array_shift($stack); + array_shift($stack); + array_shift($stack); + return $stack; } public function stopQuery() { diff --git a/lib/private/Files/Node/LazyRoot.php b/lib/private/Files/Node/LazyRoot.php index 317b8144653..1fb3f6448bc 100644 --- a/lib/private/Files/Node/LazyRoot.php +++ b/lib/private/Files/Node/LazyRoot.php @@ -139,7 +139,7 @@ class LazyRoot implements IRootFolder { * @inheritDoc */ public function get($path) { - $this->__call(__FUNCTION__, func_get_args()); + return $this->__call(__FUNCTION__, func_get_args()); } /** diff --git a/lib/private/Server.php b/lib/private/Server.php index 86eee54be70..6f6d403210d 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -185,7 +185,7 @@ class Server extends ServerContainer implements IServerContainer { }); $this->registerService('LazyRootFolder', function(Server $c) { return new LazyRoot(function() use ($c) { - return $c->getRootFolder(); + return $c->query('RootFolder'); }); }); $this->registerService('UserManager', function (Server $c) { @@ -643,19 +643,26 @@ class Server extends ServerContainer implements IServerContainer { return $factory->getManager(); }); $this->registerService('ThemingDefaults', function(Server $c) { - try { - $classExists = class_exists('OCA\Theming\ThemingDefaults'); - } catch (\OCP\AutoloadNotAllowedException $e) { - // App disabled or in maintenance mode + /* + * Dark magic for autoloader. + * If we do a class_exists it will try to load the class which will + * make composer cache the result. Resulting in errors when enabling + * the theming app. + */ + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); + if (isset($prefixes['OCA\\Theming\\'])) { + $classExists = true; + } else { $classExists = false; } - if ($classExists && $this->getConfig()->getSystemValue('installed', false) && $this->getAppManager()->isInstalled('theming')) { + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { return new ThemingDefaults( - $this->getConfig(), - $this->getL10N('theming'), - $this->getURLGenerator(), - new \OC_Defaults() + $c->getConfig(), + $c->getL10N('theming'), + $c->getURLGenerator(), + new \OC_Defaults(), + $c->getLazyRootFolder() ); } return new \OC_Defaults(); @@ -832,7 +839,7 @@ class Server extends ServerContainer implements IServerContainer { * @return \OCP\Files\IRootFolder */ public function getRootFolder() { - return $this->query('RootFolder'); + return $this->query('LazyRootFolder'); } /** @@ -1349,7 +1356,6 @@ class Server extends ServerContainer implements IServerContainer { } /** - * @internal Not public by intention. * @return \OC_Defaults */ public function getThemingDefaults() { diff --git a/lib/public/Diagnostics/IQuery.php b/lib/public/Diagnostics/IQuery.php index 9aaf7c423b9..0bd1a6d9685 100644 --- a/lib/public/Diagnostics/IQuery.php +++ b/lib/public/Diagnostics/IQuery.php @@ -47,4 +47,16 @@ interface IQuery { * @since 8.0.0 */ public function getDuration(); + + /** + * @return float + * @since 9.2.0 + */ + public function getStartTime(); + + /** + * @return array + * @since 9.2.0 + */ + public function getStacktrace(); } |