Skip to content

Commit 8e5bb02

Browse files
committed
fix: make core application bootstrapable by coordinator
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent af79414 commit 8e5bb02

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

lib/base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ public static function init(): void {
785785
if ($systemConfig->getValue('installed', false)) {
786786
$appManager->loadApp('settings');
787787
/* Build core application to make sure that listeners are registered */
788-
Server::get(\OC\Core\Application::class);
788+
$bootstrapCoordinator->runLazyRegistration('core');
789789
}
790790

791791
//make sure temporary files are cleaned up

lib/private/AppFramework/Bootstrap/Coordinator.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace OC\AppFramework\Bootstrap;
1111

12+
use OC\Core\Application;
1213
use OC\Support\CrashReport\Registry;
1314
use OC_App;
1415
use OCP\App\AppPathNotFoundException;
@@ -20,6 +21,7 @@
2021
use OCP\Diagnostics\IEventLogger;
2122
use OCP\EventDispatcher\IEventDispatcher;
2223
use OCP\IServerContainer;
24+
use Psr\Container\ContainerExceptionInterface;
2325
use Psr\Log\LoggerInterface;
2426
use Throwable;
2527
use function class_exists;
@@ -69,27 +71,32 @@ private function registerApps(array $appIds): void {
6971
*/
7072
try {
7173
$path = $this->appManager->getAppPath($appId);
74+
OC_App::registerAutoloading($appId, $path);
7275
} catch (AppPathNotFoundException) {
7376
// Ignore
7477
continue;
7578
}
76-
OC_App::registerAutoloading($appId, $path);
7779
$this->eventLogger->end("bootstrap:register_app:$appId:autoloader");
7880

7981
/*
8082
* Next we check if there is an application class, and it implements
8183
* the \OCP\AppFramework\Bootstrap\IBootstrap interface
8284
*/
83-
$appNameSpace = App::buildAppNamespace($appId);
84-
$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
85+
if ($appId === 'core') {
86+
$applicationClassName = Application::class;
87+
} else {
88+
$appNameSpace = App::buildAppNamespace($appId);
89+
$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
90+
}
91+
8592
try {
8693
if (class_exists($applicationClassName) && is_a($applicationClassName, IBootstrap::class, true)) {
8794
$this->eventLogger->start("bootstrap:register_app:$appId:application", "Load `Application` instance for $appId");
8895
try {
8996
/** @var IBootstrap&App $application */
9097
$application = $this->serverContainer->query($applicationClassName);
9198
$apps[$appId] = $application;
92-
} catch (QueryException $e) {
99+
} catch (ContainerExceptionInterface $e) {
93100
// Weird, but ok
94101
$this->eventLogger->end("bootstrap:register_app:$appId");
95102
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)