diff options
-rw-r--r-- | core/Command/App/Disable.php | 2 | ||||
-rw-r--r-- | core/Command/App/Enable.php | 2 | ||||
-rw-r--r-- | core/Command/App/Install.php | 3 | ||||
-rw-r--r-- | core/Command/App/Remove.php | 2 | ||||
-rw-r--r-- | lib/private/Installer.php | 9 | ||||
-rw-r--r-- | lib/private/Updater.php | 5 | ||||
-rw-r--r-- | lib/private/legacy/OC_App.php | 18 | ||||
-rw-r--r-- | tests/lib/InstallerTest.php | 3 |
8 files changed, 18 insertions, 26 deletions
diff --git a/core/Command/App/Disable.php b/core/Command/App/Disable.php index 05d35053b13..0ed4d29cf41 100644 --- a/core/Command/App/Disable.php +++ b/core/Command/App/Disable.php @@ -70,7 +70,7 @@ class Disable extends Command implements CompletionAwareInterface { try { $this->appManager->disableApp($appId); - $appVersion = \OC_App::getAppVersion($appId); + $appVersion = $this->appManager->getAppVersion($appId); $output->writeln($appId . ' ' . $appVersion . ' disabled'); } catch (\Exception $e) { $output->writeln($e->getMessage()); diff --git a/core/Command/App/Enable.php b/core/Command/App/Enable.php index c7a071e27b5..d50c8d79181 100644 --- a/core/Command/App/Enable.php +++ b/core/Command/App/Enable.php @@ -109,7 +109,7 @@ class Enable extends Command implements CompletionAwareInterface { } $installer->installApp($appId, $forceEnable); - $appVersion = \OC_App::getAppVersion($appId); + $appVersion = $this->appManager->getAppVersion($appId); if ($groupIds === []) { $this->appManager->enableApp($appId, $forceEnable); diff --git a/core/Command/App/Install.php b/core/Command/App/Install.php index a699a2e7af0..d87439b3664 100644 --- a/core/Command/App/Install.php +++ b/core/Command/App/Install.php @@ -28,6 +28,7 @@ namespace OC\Core\Command\App; use OC\Installer; +use OCP\App\IAppManager; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -89,7 +90,7 @@ class Install extends Command { return 1; } - $appVersion = \OC_App::getAppVersion($appId); + $appVersion = \OCP\Server::get(IAppManager::class)->getAppVersion($appId); $output->writeln($appId . ' ' . $appVersion . ' installed'); if (!$input->getOption('keep-disabled')) { diff --git a/core/Command/App/Remove.php b/core/Command/App/Remove.php index 2aa453132e4..ced17e3ef92 100644 --- a/core/Command/App/Remove.php +++ b/core/Command/App/Remove.php @@ -116,7 +116,7 @@ class Remove extends Command implements CompletionAwareInterface { return 1; } - $appVersion = \OC_App::getAppVersion($appId); + $appVersion = $this->manager->getAppVersion($appId); $output->writeln($appId . ' ' . $appVersion . ' removed'); return 0; diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 43c3db7c3fd..492efbbe4b4 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -48,6 +48,7 @@ use OC\DB\Connection; use OC\DB\MigrationService; use OC_App; use OC_Helper; +use OCP\App\IAppManager; use OCP\HintException; use OCP\Http\Client\IClientService; use OCP\IConfig; @@ -164,7 +165,7 @@ class Installer { OC_App::executeRepairSteps($appId, $info['repair-steps']['install']); //set the installed version - \OC::$server->getConfig()->setAppValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id'], false)); + \OC::$server->getConfig()->setAppValue($info['id'], 'installed_version', \OCP\Server::get(IAppManager::class)->getAppVersion($info['id'], false)); \OC::$server->getConfig()->setAppValue($info['id'], 'enabled', 'no'); //set remote/public handlers @@ -349,7 +350,7 @@ class Installer { } // Check if the version is lower than before - $currentVersion = OC_App::getAppVersion($appId); + $currentVersion = \OCP\Server::get(IAppManager::class)->getAppVersion($appId, true); $newVersion = (string)$xml->version; if (version_compare($currentVersion, $newVersion) === 1) { throw new \Exception( @@ -423,7 +424,7 @@ class Installer { foreach ($this->apps as $app) { if ($app['id'] === $appId) { - $currentVersion = OC_App::getAppVersion($appId); + $currentVersion = \OCP\Server::get(IAppManager::class)->getAppVersion($appId, true); if (!isset($app['releases'][0]['version'])) { return false; @@ -601,7 +602,7 @@ class Installer { OC_App::executeRepairSteps($app, $info['repair-steps']['install']); - $config->setAppValue($app, 'installed_version', OC_App::getAppVersion($app)); + $config->setAppValue($app, 'installed_version', \OCP\Server::get(IAppManager::class)->getAppVersion($app)); if (array_key_exists('ocsid', $info)) { $config->setAppValue($app, 'ocsid', $info['ocsid']); } diff --git a/lib/private/Updater.php b/lib/private/Updater.php index 56285166322..5a14bb17507 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -40,6 +40,7 @@ declare(strict_types=1); */ namespace OC; +use OCP\App\IAppManager; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventDispatcher; use OCP\HintException; @@ -355,9 +356,9 @@ class Updater extends BasicEmitter { $stack = $stacks[$type]; foreach ($stack as $appId) { if (\OC_App::shouldUpgrade($appId)) { - $this->emit('\OC\Updater', 'appUpgradeStarted', [$appId, \OC_App::getAppVersion($appId)]); + $this->emit('\OC\Updater', 'appUpgradeStarted', [$appId, \OCP\Server::get(IAppManager::class)->getAppVersion($appId)]); \OC_App::updateApp($appId); - $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]); + $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OCP\Server::get(IAppManager::class)->getAppVersion($appId)]); } if ($type !== $pseudoOtherType) { // load authentication, filesystem and logging apps after diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index 411f29cc19d..505bd93e0b6 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -383,18 +383,6 @@ class OC_App { } /** - * get the last version of the app from appinfo/info.xml - * - * @param string $appId - * @param bool $useCache - * @return string - * @deprecated 14.0.0 use \OC::$server->getAppManager()->getAppVersion() - */ - public static function getAppVersion(string $appId, bool $useCache = true): string { - return \OC::$server->getAppManager()->getAppVersion($appId, $useCache); - } - - /** * get app's version based on it's path * * @param string $path @@ -685,7 +673,7 @@ class OC_App { } } - $info['version'] = OC_App::getAppVersion($app); + $info['version'] = $appManager->getAppVersion($app); $appList[] = $info; } } @@ -695,7 +683,7 @@ class OC_App { public static function shouldUpgrade(string $app): bool { $versions = self::getAppVersions(); - $currentVersion = OC_App::getAppVersion($app); + $currentVersion = \OCP\Server::get(\OCP\App\IAppManager::class)->getAppVersion($app); if ($currentVersion && isset($versions[$app])) { $installedVersion = $versions[$app]; if (!version_compare($currentVersion, $installedVersion, '=')) { @@ -853,7 +841,7 @@ class OC_App { self::setAppTypes($appId); - $version = \OC_App::getAppVersion($appId); + $version = \OCP\Server::get(\OCP\App\IAppManager::class)->getAppVersion($appId); \OC::$server->getConfig()->setAppValue($appId, 'installed_version', $version); \OC::$server->get(IEventDispatcher::class)->dispatchTyped(new AppUpdateEvent($appId)); diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php index 352580337ad..60c8ac1cc94 100644 --- a/tests/lib/InstallerTest.php +++ b/tests/lib/InstallerTest.php @@ -11,6 +11,7 @@ namespace Test; use OC\App\AppStore\Fetcher\AppFetcher; use OC\Archive\ZIP; use OC\Installer; +use OCP\App\IAppManager; use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\IConfig; @@ -88,7 +89,7 @@ class InstallerTest extends TestCase { public function testInstallApp() { // Read the current version of the app to check for bug #2572 - \OC_App::getAppVersion('testapp'); + \OCP\Server::get(IAppManager::class)->getAppVersion('testapp', true); // Extract app $pathOfTestApp = __DIR__ . '/../data/testapp.zip'; |