Compare commits

...

1 Commits

Author SHA1 Message Date
nfebe d4dccb2ff6 feat(apps): Make app enabling atomic
Previously, if an app failed during its enabling process,
it could leave the instance in a broken state. This was
because the app was marked as enabled before its
initialization code was executed, but the state was not
rolled back upon failure.

This change wraps the app enabling logic in a try/catch
block. If the app's initialization fails, the 'enabled'
state is reverted in the database, and the in-memory
app cache is cleared. This ensures that a faulty app
cannot take down the entire Nextcloud instance.

Signed-off-by: nfebe <fenn25.fn@gmail.com>
2025-11-19 10:32:37 +01:00
+12 -4
View File
@@ -591,10 +591,18 @@ class AppManager implements IAppManager {
$this->enabledAppsCache[$appId] = 'yes';
$this->getAppConfig()->setValue($appId, 'enabled', 'yes');
$this->dispatcher->dispatchTyped(new AppEnableEvent($appId));
$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent(
ManagerEvent::EVENT_APP_ENABLE, $appId
));
try {
$this->dispatcher->dispatchTyped(new AppEnableEvent($appId));
$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent(
ManagerEvent::EVENT_APP_ENABLE, $appId
));
} catch (\Throwable $e) {
$this->getAppConfig()->setValue($appId, 'enabled', 'no');
unset($this->enabledAppsCache[$appId]);
throw $e;
}
$this->clearAppsCache();
$this->configManager->migrateConfigLexiconKeys($appId);