chore: Drop \OC_App::getAppVersion

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
pull/38566/head
Christoph Wurst 3 years ago
parent 2be74ee175
commit cf6e2fa1b7
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
  1. 2
      core/Command/App/Disable.php
  2. 2
      core/Command/App/Enable.php
  3. 3
      core/Command/App/Install.php
  4. 2
      core/Command/App/Remove.php
  5. 9
      lib/private/Installer.php
  6. 5
      lib/private/Updater.php
  7. 18
      lib/private/legacy/OC_App.php
  8. 3
      tests/lib/InstallerTest.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());

@ -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);

@ -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')) {

@ -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;

@ -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']);
}

@ -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

@ -382,18 +382,6 @@ class OC_App {
return false;
}
/**
* 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
*
@ -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));

@ -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';

Loading…
Cancel
Save