diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-05-28 13:26:07 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-06-02 15:58:54 +0200 |
commit | c21e1898508f172b95a21e5f4cacb4ad22fc628e (patch) | |
tree | 8e516db5f711bd9d291c6174eae9c31ad23d30e3 /lib/private | |
parent | 0a982374ecbfe05d28faf3385ec84a98eb84b4e8 (diff) | |
download | nextcloud-server-chore/refactor-core.tar.gz nextcloud-server-chore/refactor-core.zip |
fix: make core application bootstrapable by coordinatorchore/refactor-core
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>
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/App/AppManager.php | 4 | ||||
-rw-r--r-- | lib/private/AppFramework/Bootstrap/Coordinator.php | 12 | ||||
-rw-r--r-- | lib/private/URLGenerator.php | 6 | ||||
-rw-r--r-- | lib/private/legacy/OC_App.php | 2 |
4 files changed, 18 insertions, 6 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index f6494fa946d..413dc6ccd46 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -812,6 +812,10 @@ class AppManager implements IAppManager { } private function isAlwaysEnabled(string $appId): bool { + if ($appId === 'core') { + return true; + } + $alwaysEnabled = $this->getAlwaysEnabledApps(); return in_array($appId, $alwaysEnabled, true); } diff --git a/lib/private/AppFramework/Bootstrap/Coordinator.php b/lib/private/AppFramework/Bootstrap/Coordinator.php index 4e613703dec..190244051d3 100644 --- a/lib/private/AppFramework/Bootstrap/Coordinator.php +++ b/lib/private/AppFramework/Bootstrap/Coordinator.php @@ -20,6 +20,7 @@ use OCP\Dashboard\IManager; use OCP\Diagnostics\IEventLogger; use OCP\EventDispatcher\IEventDispatcher; use OCP\IServerContainer; +use Psr\Container\ContainerExceptionInterface; use Psr\Log\LoggerInterface; use Throwable; use function class_exists; @@ -69,19 +70,24 @@ class Coordinator { */ try { $path = $this->appManager->getAppPath($appId); + OC_App::registerAutoloading($appId, $path); } catch (AppPathNotFoundException) { // Ignore continue; } - OC_App::registerAutoloading($appId, $path); $this->eventLogger->end("bootstrap:register_app:$appId:autoloader"); /* * Next we check if there is an application class, and it implements * the \OCP\AppFramework\Bootstrap\IBootstrap interface */ - $appNameSpace = App::buildAppNamespace($appId); + if ($appId === 'core') { + $appNameSpace = 'OC\\Core'; + } else { + $appNameSpace = App::buildAppNamespace($appId); + } $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; + try { if (class_exists($applicationClassName) && is_a($applicationClassName, IBootstrap::class, true)) { $this->eventLogger->start("bootstrap:register_app:$appId:application", "Load `Application` instance for $appId"); @@ -89,7 +95,7 @@ class Coordinator { /** @var IBootstrap&App $application */ $application = $this->serverContainer->query($applicationClassName); $apps[$appId] = $application; - } catch (QueryException $e) { + } catch (ContainerExceptionInterface $e) { // Weird, but ok $this->eventLogger->end("bootstrap:register_app:$appId"); continue; diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index c78ecac0903..1a2978b84d7 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -189,14 +189,14 @@ class URLGenerator implements IURLGenerator { $basename = substr(basename($file), 0, -4); try { - $appPath = $this->getAppManager()->getAppPath($appName); - } catch (AppPathNotFoundException $e) { if ($appName === 'core' || $appName === '') { $appName = 'core'; $appPath = false; } else { - throw new RuntimeException('image not found: image: ' . $file . ' webroot: ' . \OC::$WEBROOT . ' serverroot: ' . \OC::$SERVERROOT); + $appPath = $this->getAppManager()->getAppPath($appName); } + } catch (AppPathNotFoundException $e) { + throw new RuntimeException('image not found: image: ' . $file . ' webroot: ' . \OC::$WEBROOT . ' serverroot: ' . \OC::$SERVERROOT); } // Check if the app is in the app folder diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index abac0d2635e..4f0fff8884e 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -316,6 +316,8 @@ class OC_App { $appId = self::cleanAppId($appId); if ($appId === '') { return false; + } elseif ($appId === 'core') { + return __DIR__ . '/../../../core'; } if (($dir = self::findAppInDirectories($appId, $refreshAppPath)) != false) { |