Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2019-10-16 13:16:49 +0300
committerJoas Schilling <coding@schilljs.com>2019-10-16 13:17:09 +0300
commitaad535e3afe6fb84313cbc8160f93177b92e46a0 (patch)
tree499e98cc3968a01c10ebc61a6b5cc4249bd29732 /lib/public/AppFramework
parentf7319e139dfcfcd6309ce94cb514ebb58a4b49ad (diff)
Log an error in development cases when the application class was set up incorrectly
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/public/AppFramework')
-rw-r--r--lib/public/AppFramework/App.php27
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/public/AppFramework/App.php b/lib/public/AppFramework/App.php
index 06524e4bf02..3b42b28758d 100644
--- a/lib/public/AppFramework/App.php
+++ b/lib/public/AppFramework/App.php
@@ -34,6 +34,7 @@ declare(strict_types=1);
namespace OCP\AppFramework;
use OC\AppFramework\Routing\RouteConfig;
+use OC\ServerContainer;
use OCP\Route\IRouter;
@@ -51,8 +52,8 @@ class App {
private $container;
/**
- * Turns an app id into a namespace by convetion. The id is split at the
- * underscores, all parts are camelcased and reassembled. e.g.:
+ * Turns an app id into a namespace by convention. The id is split at the
+ * underscores, all parts are CamelCased and reassembled. e.g.:
* some_app_id -> OCA\SomeAppId
* @param string $appId the app id
* @param string $topNamespace the namespace which should be prepended to
@@ -71,6 +72,28 @@ class App {
* @since 6.0.0
*/
public function __construct(string $appName, array $urlParams = []) {
+ if (\OC::$server->getConfig()->getSystemValueBool('debug')) {
+ $applicationClassName = get_class($this);
+ $e = new \RuntimeException('App class ' . $applicationClassName . ' is not setup via query() but directly');
+ $setUpViaQuery = false;
+
+ foreach ($e->getTrace() as $step) {
+ if (isset($step['class'], $step['function'], $step['args'][0]) &&
+ $step['class'] === ServerContainer::class &&
+ $step['function'] === 'query' &&
+ $step['args'][0] === $applicationClassName) {
+ $setUpViaQuery = true;
+ break;
+ }
+ }
+
+ if (!$setUpViaQuery) {
+ \OC::$server->getLogger()->logException($e, [
+ 'app' => $appName,
+ ]);
+ }
+ }
+
try {
$this->container = \OC::$server->getRegisteredAppContainer($appName);
} catch (QueryException $e) {