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 2c87ce6 commit 7d3c308
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
10 changes: 7 additions & 3 deletions lib/private/AppFramework/Bootstrap/Coordinator.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,15 @@ public function runRegistration(): void {
$context->delegateSearchProviderRegistration($apps, $this->searchComposer);
}

public function bootApp(string $appId): void {
/**
* @return bool indicates if the booted app was an IBootstrap one
*/
public function bootApp(string $appId): bool {
$appNameSpace = App::buildAppNamespace($appId);
$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
if (!class_exists($applicationClassName)) {
// Nothing to boot
return;
return false;
}

/*
Expand All @@ -142,17 +145,18 @@ public function bootApp(string $appId): void {
/** @var BootContext $context */
$context = new BootContext($application->getContainer());
$application->boot($context);
return true;
}
} catch (QueryException $e) {
$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,
]);
}
return false;
}
}
16 changes: 11 additions & 5 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);
$isBootstrapApp = $coordinator->bootApp($app);

$hasAppPHPFile = is_file($appPath . '/appinfo/app.php');

if ($isBootstrapApp && $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 @@ -176,10 +186,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);
if (!empty($info['activity']['filters'])) {
foreach ($info['activity']['filters'] as $filter) {
Expand Down

0 comments on commit 7d3c308

Please sign in to comment.