]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do not load app.php if Application implements IBootstrap 21812/head
authorMorris Jobke <hey@morrisjobke.de>
Mon, 13 Jul 2020 12:58:52 +0000 (14:58 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Tue, 14 Jul 2020 13:55:23 +0000 (15:55 +0200)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
lib/private/AppFramework/Bootstrap/Coordinator.php
lib/private/legacy/OC_App.php

index 085e7460da6d5df2d4cd52f07711af767504ac1c..8a513d65029531f8ee4b963e4a4c6787d28b6351 100644 (file)
@@ -147,7 +147,6 @@ class Coordinator {
                        $this->logger->logException($e, [
                                'message' => "Could not boot $appId" . $e->getMessage(),
                        ]);
-                       return;
                } catch (Throwable $e) {
                        $this->logger->logException($e, [
                                'message' => "Could not boot $appId" . $e->getMessage(),
@@ -155,4 +154,11 @@ class Coordinator {
                        ]);
                }
        }
+
+       public function isBootable(string $appId) {
+               $appNameSpace = App::buildAppNamespace($appId);
+               $applicationClassName = $appNameSpace . '\\AppInfo\\Application';
+               return class_exists($applicationClassName) &&
+                       in_array(IBootstrap::class, class_implements($applicationClassName), true);
+       }
 }
index f4308dae2fd6fbe39d2c6691ee2c350162f47c13..4110bee114d5d673ac32f0ead1c840ba37870c55 100644 (file)
@@ -149,7 +149,17 @@ class OC_App {
                // in case someone calls loadApp() directly
                self::registerAutoloading($app, $appPath);
 
-               if (is_file($appPath . '/appinfo/app.php')) {
+               /** @var \OC\AppFramework\Bootstrap\Coordinator $coordinator */
+               $coordinator = \OC::$server->query(\OC\AppFramework\Bootstrap\Coordinator::class);
+               $isBootable = $coordinator->isBootable($app);
+
+               $hasAppPhpFile = is_file($appPath . '/appinfo/app.php');
+
+               if ($isBootable && $hasAppPhpFile) {
+                       \OC::$server->getLogger()->error('/appinfo/app.php is not loaded when \OCP\AppFramework\Bootstrap\IBootstrap on the application class is used. Migrate everything from app.php to the Application class.', [
+                               'app' => $app,
+                       ]);
+               } elseif ($hasAppPhpFile) {
                        \OC::$server->getLogger()->debug('/appinfo/app.php is deprecated, use \OCP\AppFramework\Bootstrap\IBootstrap on the application class instead.', [
                                'app' => $app,
                        ]);
@@ -175,9 +185,6 @@ class OC_App {
                        }
                        \OC::$server->getEventLogger()->end('load_app_' . $app);
                }
-
-               /** @var \OC\AppFramework\Bootstrap\Coordinator $coordinator */
-               $coordinator = \OC::$server->query(\OC\AppFramework\Bootstrap\Coordinator::class);
                $coordinator->bootApp($app);
 
                $info = self::getAppInfo($app);