Skip to content

Commit c21e189

Browse files
susnuxcome-nc
andcommitted
fix: make core application bootstrapable by coordinator
Co-authored-by: Ferdinand Thiessen <opensource@fthiessen.de> Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com> Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 0a98237 commit c21e189

File tree

8 files changed

+23
-11
lines changed

8 files changed

+23
-11
lines changed

core/Application.php renamed to core/AppInfo/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
66
* SPDX-License-Identifier: AGPL-3.0-only
77
*/
8-
namespace OC\Core;
8+
namespace OC\Core\AppInfo;
99

1010
use OC\Authentication\Events\RemoteWipeFinished;
1111
use OC\Authentication\Events\RemoteWipeStarted;

lib/base.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,8 @@ public static function init(): void {
784784
// Make sure that the application class is not loaded before the database is setup
785785
if ($systemConfig->getValue('installed', false)) {
786786
$appManager->loadApp('settings');
787-
/* Build core application to make sure that listeners are registered */
788-
Server::get(\OC\Core\Application::class);
787+
/* Run core application registration */
788+
$bootstrapCoordinator->runLazyRegistration('core');
789789
}
790790

791791
//make sure temporary files are cleaned up

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@
12021202
'OC\\Contacts\\ContactsMenu\\Providers\\EMailProvider' => $baseDir . '/lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php',
12031203
'OC\\Contacts\\ContactsMenu\\Providers\\LocalTimeProvider' => $baseDir . '/lib/private/Contacts/ContactsMenu/Providers/LocalTimeProvider.php',
12041204
'OC\\Contacts\\ContactsMenu\\Providers\\ProfileProvider' => $baseDir . '/lib/private/Contacts/ContactsMenu/Providers/ProfileProvider.php',
1205-
'OC\\Core\\Application' => $baseDir . '/core/Application.php',
1205+
'OC\\Core\\AppInfo\\Application' => $baseDir . '/core/AppInfo/Application.php',
12061206
'OC\\Core\\BackgroundJobs\\BackgroundCleanupUpdaterBackupsJob' => $baseDir . '/core/BackgroundJobs/BackgroundCleanupUpdaterBackupsJob.php',
12071207
'OC\\Core\\BackgroundJobs\\CheckForUserCertificates' => $baseDir . '/core/BackgroundJobs/CheckForUserCertificates.php',
12081208
'OC\\Core\\BackgroundJobs\\CleanupLoginFlowV2' => $baseDir . '/core/BackgroundJobs/CleanupLoginFlowV2.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
12431243
'OC\\Contacts\\ContactsMenu\\Providers\\EMailProvider' => __DIR__ . '/../../..' . '/lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php',
12441244
'OC\\Contacts\\ContactsMenu\\Providers\\LocalTimeProvider' => __DIR__ . '/../../..' . '/lib/private/Contacts/ContactsMenu/Providers/LocalTimeProvider.php',
12451245
'OC\\Contacts\\ContactsMenu\\Providers\\ProfileProvider' => __DIR__ . '/../../..' . '/lib/private/Contacts/ContactsMenu/Providers/ProfileProvider.php',
1246-
'OC\\Core\\Application' => __DIR__ . '/../../..' . '/core/Application.php',
1246+
'OC\\Core\\AppInfo\\Application' => __DIR__ . '/../../..' . '/core/AppInfo/Application.php',
12471247
'OC\\Core\\BackgroundJobs\\BackgroundCleanupUpdaterBackupsJob' => __DIR__ . '/../../..' . '/core/BackgroundJobs/BackgroundCleanupUpdaterBackupsJob.php',
12481248
'OC\\Core\\BackgroundJobs\\CheckForUserCertificates' => __DIR__ . '/../../..' . '/core/BackgroundJobs/CheckForUserCertificates.php',
12491249
'OC\\Core\\BackgroundJobs\\CleanupLoginFlowV2' => __DIR__ . '/../../..' . '/core/BackgroundJobs/CleanupLoginFlowV2.php',

lib/private/App/AppManager.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,10 @@ public function isShipped($appId) {
812812
}
813813

814814
private function isAlwaysEnabled(string $appId): bool {
815+
if ($appId === 'core') {
816+
return true;
817+
}
818+
815819
$alwaysEnabled = $this->getAlwaysEnabledApps();
816820
return in_array($appId, $alwaysEnabled, true);
817821
}

lib/private/AppFramework/Bootstrap/Coordinator.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use OCP\Diagnostics\IEventLogger;
2121
use OCP\EventDispatcher\IEventDispatcher;
2222
use OCP\IServerContainer;
23+
use Psr\Container\ContainerExceptionInterface;
2324
use Psr\Log\LoggerInterface;
2425
use Throwable;
2526
use function class_exists;
@@ -69,27 +70,32 @@ private function registerApps(array $appIds): void {
6970
*/
7071
try {
7172
$path = $this->appManager->getAppPath($appId);
73+
OC_App::registerAutoloading($appId, $path);
7274
} catch (AppPathNotFoundException) {
7375
// Ignore
7476
continue;
7577
}
76-
OC_App::registerAutoloading($appId, $path);
7778
$this->eventLogger->end("bootstrap:register_app:$appId:autoloader");
7879

7980
/*
8081
* Next we check if there is an application class, and it implements
8182
* the \OCP\AppFramework\Bootstrap\IBootstrap interface
8283
*/
83-
$appNameSpace = App::buildAppNamespace($appId);
84+
if ($appId === 'core') {
85+
$appNameSpace = 'OC\\Core';
86+
} else {
87+
$appNameSpace = App::buildAppNamespace($appId);
88+
}
8489
$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
90+
8591
try {
8692
if (class_exists($applicationClassName) && is_a($applicationClassName, IBootstrap::class, true)) {
8793
$this->eventLogger->start("bootstrap:register_app:$appId:application", "Load `Application` instance for $appId");
8894
try {
8995
/** @var IBootstrap&App $application */
9096
$application = $this->serverContainer->query($applicationClassName);
9197
$apps[$appId] = $application;
92-
} catch (QueryException $e) {
98+
} catch (ContainerExceptionInterface $e) {
9399
// Weird, but ok
94100
$this->eventLogger->end("bootstrap:register_app:$appId");
95101
continue;

lib/private/URLGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ public function imagePath(string $appName, string $file): string {
189189
$basename = substr(basename($file), 0, -4);
190190

191191
try {
192-
$appPath = $this->getAppManager()->getAppPath($appName);
193-
} catch (AppPathNotFoundException $e) {
194192
if ($appName === 'core' || $appName === '') {
195193
$appName = 'core';
196194
$appPath = false;
197195
} else {
198-
throw new RuntimeException('image not found: image: ' . $file . ' webroot: ' . \OC::$WEBROOT . ' serverroot: ' . \OC::$SERVERROOT);
196+
$appPath = $this->getAppManager()->getAppPath($appName);
199197
}
198+
} catch (AppPathNotFoundException $e) {
199+
throw new RuntimeException('image not found: image: ' . $file . ' webroot: ' . \OC::$WEBROOT . ' serverroot: ' . \OC::$SERVERROOT);
200200
}
201201

202202
// Check if the app is in the app folder

lib/private/legacy/OC_App.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ public static function getAppPath(string $appId, bool $refreshAppPath = false) {
316316
$appId = self::cleanAppId($appId);
317317
if ($appId === '') {
318318
return false;
319+
} elseif ($appId === 'core') {
320+
return __DIR__ . '/../../../core';
319321
}
320322

321323
if (($dir = self::findAppInDirectories($appId, $refreshAppPath)) != false) {

0 commit comments

Comments
 (0)