Skip to content

Commit

Permalink
Do not load app.php if Application implements IBootstrap
Browse files Browse the repository at this point in the history
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed Jul 14, 2020
1 parent 7b82895 commit d6339e7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
8 changes: 7 additions & 1 deletion lib/private/AppFramework/Bootstrap/Coordinator.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,18 @@ public function bootApp(string $appId): void {
$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(),
'level' => ILogger::FATAL,
]);
}
}

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);
}
}
15 changes: 11 additions & 4 deletions lib/private/legacy/OC_App.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,17 @@ public static function loadApp(string $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,
]);
Expand All @@ -175,9 +185,6 @@ public static function loadApp(string $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);
Expand Down

0 comments on commit d6339e7

Please sign in to comment.