Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(lexicon): migrate keys on app update
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Jun 24, 2025
commit 3d3c77b7746fbf3eb41ded8612099a351fd36224
13 changes: 7 additions & 6 deletions lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Server;
use OCP\ServerVersion;
use OCP\Settings\IManager as ISettingsManager;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -88,7 +89,7 @@ public function __construct(

private function getNavigationManager(): INavigationManager {
if ($this->navigationManager === null) {
$this->navigationManager = \OCP\Server::get(INavigationManager::class);
$this->navigationManager = Server::get(INavigationManager::class);
}
return $this->navigationManager;
}
Expand All @@ -114,7 +115,7 @@ private function getAppConfig(): AppConfig {
if (!$this->config->getSystemValueBool('installed', false)) {
throw new \Exception('Nextcloud is not installed yet, AppConfig is not available');
}
$this->appConfig = \OCP\Server::get(AppConfig::class);
$this->appConfig = Server::get(AppConfig::class);
return $this->appConfig;
}

Expand All @@ -125,7 +126,7 @@ private function getUrlGenerator(): IURLGenerator {
if (!$this->config->getSystemValueBool('installed', false)) {
throw new \Exception('Nextcloud is not installed yet, AppConfig is not available');
}
$this->urlGenerator = \OCP\Server::get(IURLGenerator::class);
$this->urlGenerator = Server::get(IURLGenerator::class);
return $this->urlGenerator;
}

Expand Down Expand Up @@ -460,7 +461,7 @@ public function loadApp(string $app): void {
]);
}

$coordinator = \OCP\Server::get(Coordinator::class);
$coordinator = Server::get(Coordinator::class);
$coordinator->bootApp($app);

$eventLogger->start("bootstrap:load_app:$app:info", "Load info.xml for $app and register any services defined in it");
Expand Down Expand Up @@ -570,7 +571,7 @@ public function enableApp(string $appId, bool $forceEnable = false): void {
));
$this->clearAppsCache();

\OCP\Server::get(ConfigManager::class)->migrateConfigLexiconKeys($appId);
Server::get(ConfigManager::class)->migrateConfigLexiconKeys($appId);
}

/**
Expand Down Expand Up @@ -630,7 +631,7 @@ public function enableAppForGroups(string $appId, array $groups, bool $forceEnab
));
$this->clearAppsCache();

\OCP\Server::get(ConfigManager::class)->migrateConfigLexiconKeys($appId);
Server::get(ConfigManager::class)->migrateConfigLexiconKeys($appId);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions lib/private/legacy/OC_App.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use OC\App\DependencyAnalyzer;
use OC\App\Platform;
use OC\AppFramework\Bootstrap\Coordinator;
use OC\Config\ConfigManager;
use OC\DB\MigrationService;
use OC\Installer;
use OC\Repair;
Expand Down Expand Up @@ -714,6 +715,9 @@ public static function updateApp(string $appId): bool {
$version = \OCP\Server::get(\OCP\App\IAppManager::class)->getAppVersion($appId);
\OC::$server->getConfig()->setAppValue($appId, 'installed_version', $version);

// migrate eventual new config keys in the process
Server::get(ConfigManager::class)->migrateConfigLexiconKeys($appId);

\OC::$server->get(IEventDispatcher::class)->dispatchTyped(new AppUpdateEvent($appId));
\OC::$server->get(IEventDispatcher::class)->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent(
ManagerEvent::EVENT_APP_UPDATE, $appId
Expand Down
8 changes: 3 additions & 5 deletions lib/public/App/Events/AppUpdateEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
* @since 27.0.0
*/
class AppUpdateEvent extends Event {
private string $appId;

/**
* @since 27.0.0
*/
public function __construct(string $appId) {
public function __construct(
private readonly string $appId,
) {
parent::__construct();

$this->appId = $appId;
}

/**
Expand Down