aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php8
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/App/AppStore/Fetcher/Fetcher.php4
-rw-r--r--lib/private/Console/Application.php4
-rw-r--r--lib/private/IntegrityCheck/Checker.php4
-rw-r--r--lib/private/IntegrityCheck/Helpers/EnvironmentHelper.php9
-rw-r--r--lib/private/Server.php12
-rw-r--r--lib/private/Setup.php5
-rw-r--r--lib/private/Template/JSConfigHelper.php8
-rw-r--r--lib/private/TemplateLayout.php2
-rw-r--r--lib/private/Updater.php6
-rw-r--r--lib/private/Updater/VersionCheck.php6
-rw-r--r--lib/private/legacy/OC_Defaults.php9
-rw-r--r--lib/private/legacy/OC_Util.php84
-rw-r--r--lib/public/ServerVersion.php102
-rw-r--r--lib/public/Util.php10
17 files changed, 157 insertions, 118 deletions
diff --git a/lib/base.php b/lib/base.php
index ec5cf3759f2..5bab5d9f3f6 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -292,10 +292,12 @@ class OC {
http_response_code(503);
header('Retry-After: 120');
+ $serverVersion = \OCP\Server::get(\OCP\ServerVersion::class);
+
// render error page
$template = new OC_Template('', 'update.use-cli', 'guest');
$template->assign('productName', 'nextcloud'); // for now
- $template->assign('version', OC_Util::getVersionString());
+ $template->assign('version', $serverVersion->getVersionString());
$template->assign('tooBig', $tooBig);
$template->assign('cliUpgradeLink', $cliUpgradeLink);
@@ -321,7 +323,7 @@ class OC {
$appManager = Server::get(\OCP\App\IAppManager::class);
$tmpl = new OC_Template('', 'update.admin', 'guest');
- $tmpl->assign('version', OC_Util::getVersionString());
+ $tmpl->assign('version', \OCP\Server::get(\OCP\ServerVersion::class)->getVersionString());
$tmpl->assign('isAppsOnlyUpgrade', $isAppsOnlyUpgrade);
// get third party apps
@@ -663,7 +665,7 @@ class OC {
if (!function_exists('simplexml_load_file')) {
throw new \OCP\HintException('The PHP SimpleXML/PHP-XML extension is not installed.', 'Install the extension or make sure it is enabled.');
}
-
+
OC_App::loadApps(['session']);
if (!self::$CLI) {
self::initSession();
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 82964a6e6c7..166d5805bdc 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -688,6 +688,7 @@ return array(
'OCP\\Security\\VerificationToken\\IVerificationToken' => $baseDir . '/lib/public/Security/VerificationToken/IVerificationToken.php',
'OCP\\Security\\VerificationToken\\InvalidTokenException' => $baseDir . '/lib/public/Security/VerificationToken/InvalidTokenException.php',
'OCP\\Server' => $baseDir . '/lib/public/Server.php',
+ 'OCP\\ServerVersion' => $baseDir . '/lib/public/ServerVersion.php',
'OCP\\Session\\Exceptions\\SessionNotAvailableException' => $baseDir . '/lib/public/Session/Exceptions/SessionNotAvailableException.php',
'OCP\\Settings\\DeclarativeSettingsTypes' => $baseDir . '/lib/public/Settings/DeclarativeSettingsTypes.php',
'OCP\\Settings\\Events\\DeclarativeSettingsGetValueEvent' => $baseDir . '/lib/public/Settings/Events/DeclarativeSettingsGetValueEvent.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index d83229c7426..b455077b958 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -721,6 +721,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Security\\VerificationToken\\IVerificationToken' => __DIR__ . '/../../..' . '/lib/public/Security/VerificationToken/IVerificationToken.php',
'OCP\\Security\\VerificationToken\\InvalidTokenException' => __DIR__ . '/../../..' . '/lib/public/Security/VerificationToken/InvalidTokenException.php',
'OCP\\Server' => __DIR__ . '/../../..' . '/lib/public/Server.php',
+ 'OCP\\ServerVersion' => __DIR__ . '/../../..' . '/lib/public/ServerVersion.php',
'OCP\\Session\\Exceptions\\SessionNotAvailableException' => __DIR__ . '/../../..' . '/lib/public/Session/Exceptions/SessionNotAvailableException.php',
'OCP\\Settings\\DeclarativeSettingsTypes' => __DIR__ . '/../../..' . '/lib/public/Settings/DeclarativeSettingsTypes.php',
'OCP\\Settings\\Events\\DeclarativeSettingsGetValueEvent' => __DIR__ . '/../../..' . '/lib/public/Settings/Events/DeclarativeSettingsGetValueEvent.php',
diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php
index edb96b55f0a..f998c9e2023 100644
--- a/lib/private/App/AppStore/Fetcher/Fetcher.php
+++ b/lib/private/App/AppStore/Fetcher/Fetcher.php
@@ -13,6 +13,8 @@ use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
+use OCP\Server;
+use OCP\ServerVersion;
use OCP\Support\Subscription\IRegistry;
use Psr\Log\LoggerInterface;
@@ -207,7 +209,7 @@ abstract class Fetcher {
*/
protected function getChannel() {
if ($this->channel === null) {
- $this->channel = \OC_Util::getChannel();
+ $this->channel = Server::get(ServerVersion::class)->getChannel();
}
return $this->channel;
}
diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php
index 1b620089736..ac30a93a186 100644
--- a/lib/private/Console/Application.php
+++ b/lib/private/Console/Application.php
@@ -19,6 +19,7 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IRequest;
use OCP\Server;
+use OCP\ServerVersion;
use Psr\Container\ContainerExceptionInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Application as SymfonyApplication;
@@ -31,6 +32,7 @@ class Application {
private SymfonyApplication $application;
public function __construct(
+ ServerVersion $serverVersion,
private IConfig $config,
private IEventDispatcher $dispatcher,
private IRequest $request,
@@ -39,7 +41,7 @@ class Application {
private IAppManager $appManager,
private Defaults $defaults,
) {
- $this->application = new SymfonyApplication($defaults->getName(), \OC_Util::getVersionString());
+ $this->application = new SymfonyApplication($defaults->getName(), $serverVersion->getVersionString());
}
/**
diff --git a/lib/private/IntegrityCheck/Checker.php b/lib/private/IntegrityCheck/Checker.php
index a6a61555957..3a24e8632de 100644
--- a/lib/private/IntegrityCheck/Checker.php
+++ b/lib/private/IntegrityCheck/Checker.php
@@ -21,6 +21,7 @@ use OCP\IAppConfig;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IConfig;
+use OCP\ServerVersion;
use phpseclib\Crypt\RSA;
use phpseclib\File\X509;
@@ -40,6 +41,7 @@ class Checker {
private ICache $cache;
public function __construct(
+ private ServerVersion $serverVersion,
private EnvironmentHelper $environmentHelper,
private FileAccessHelper $fileAccessHelper,
private AppLocator $appLocator,
@@ -59,7 +61,7 @@ class Checker {
*/
public function isCodeCheckEnforced(): bool {
$notSignedChannels = [ '', 'git'];
- if (\in_array($this->environmentHelper->getChannel(), $notSignedChannels, true)) {
+ if (\in_array($this->serverVersion->getChannel(), $notSignedChannels, true)) {
return false;
}
diff --git a/lib/private/IntegrityCheck/Helpers/EnvironmentHelper.php b/lib/private/IntegrityCheck/Helpers/EnvironmentHelper.php
index dcdc7839f8e..583ae5e534f 100644
--- a/lib/private/IntegrityCheck/Helpers/EnvironmentHelper.php
+++ b/lib/private/IntegrityCheck/Helpers/EnvironmentHelper.php
@@ -23,13 +23,4 @@ class EnvironmentHelper {
public function getServerRoot(): string {
return rtrim(\OC::$SERVERROOT, '/');
}
-
- /**
- * Provides \OC_Util::getChannel()
- *
- * @return string
- */
- public function getChannel(): string {
- return \OC_Util::getChannel();
- }
}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 943b4fc6997..19c3b72c11c 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -216,6 +216,7 @@ use OCP\Security\ISecureRandom;
use OCP\Security\ITrustedDomainHelper;
use OCP\Security\RateLimiting\ILimiter;
use OCP\Security\VerificationToken\IVerificationToken;
+use OCP\ServerVersion;
use OCP\Settings\IDeclarativeManager;
use OCP\SetupCheck\ISetupCheckManager;
use OCP\Share\IProviderFactory;
@@ -593,10 +594,12 @@ class Server extends ServerContainer implements IServerContainer {
);
/** @var SystemConfig $config */
$config = $c->get(SystemConfig::class);
+ /** @var ServerVersion $serverVersion */
+ $serverVersion = $c->get(ServerVersion::class);
if ($config->getValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
$logQuery = $config->getValue('log_query');
- $prefixClosure = function () use ($logQuery) {
+ $prefixClosure = function () use ($logQuery, $serverVersion) {
if (!$logQuery) {
try {
$v = \OC_App::getAppVersions();
@@ -613,7 +616,7 @@ class Server extends ServerContainer implements IServerContainer {
'log_query' => 'enabled',
];
}
- $v['core'] = implode(',', \OC_Util::getVersion());
+ $v['core'] = implode(',', $serverVersion->getVersion());
$version = implode(',', $v);
$instanceId = \OC_Util::getInstanceId();
$path = \OC::$SERVERROOT;
@@ -865,7 +868,8 @@ class Server extends ServerContainer implements IServerContainer {
$appManager = $c->get(IAppManager::class);
return new Checker(
- new EnvironmentHelper(),
+ $c->get(ServerVersion::class),
+ $c->get(EnvironmentHelper::class),
new FileAccessHelper(),
new AppLocator(),
$config,
@@ -1056,7 +1060,7 @@ class Server extends ServerContainer implements IServerContainer {
$c->get(IUserSession::class),
$c->get(IURLGenerator::class),
$c->get(ICacheFactory::class),
- new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
+ new Util($c->get(ServerVersion::class), $c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming'), $imageManager),
$imageManager,
$c->get(IAppManager::class),
$c->get(INavigationManager::class),
diff --git a/lib/private/Setup.php b/lib/private/Setup.php
index fa10f238bde..e64f6806b87 100644
--- a/lib/private/Setup.php
+++ b/lib/private/Setup.php
@@ -32,6 +32,7 @@ use OCP\L10N\IFactory as IL10NFactory;
use OCP\Migration\IOutput;
use OCP\Security\ISecureRandom;
use OCP\Server;
+use OCP\ServerVersion;
use Psr\Log\LoggerInterface;
class Setup {
@@ -380,7 +381,7 @@ class Setup {
unlink(\OC::$configDir . '/CAN_INSTALL');
}
- $bootstrapCoordinator = \OCP\Server::get(\OC\AppFramework\Bootstrap\Coordinator::class);
+ $bootstrapCoordinator = Server::get(\OC\AppFramework\Bootstrap\Coordinator::class);
$bootstrapCoordinator->runInitialRegistration();
// Create a session token for the newly created user
@@ -561,7 +562,7 @@ class Setup {
}
public function shouldRemoveCanInstallFile(): bool {
- return \OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir . '/CAN_INSTALL');
+ return Server::get(ServerVersion::class)->getChannel() !== 'git' && is_file(\OC::$configDir . '/CAN_INSTALL');
}
public function canInstallFileExists(): bool {
diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php
index 1dec8634aca..44563f2938c 100644
--- a/lib/private/Template/JSConfigHelper.php
+++ b/lib/private/Template/JSConfigHelper.php
@@ -30,6 +30,7 @@ use OCP\ILogger;
use OCP\ISession;
use OCP\IURLGenerator;
use OCP\IUser;
+use OCP\ServerVersion;
use OCP\Session\Exceptions\SessionNotAvailableException;
use OCP\Share\IManager as IShareManager;
use OCP\User\Backend\IPasswordConfirmationBackend;
@@ -41,6 +42,7 @@ class JSConfigHelper {
private $excludedUserBackEnds = ['user_saml' => true, 'user_globalsiteselector' => true];
public function __construct(
+ protected ServerVersion $serverVersion,
protected IL10N $l,
protected Defaults $defaults,
protected IAppManager $appManager,
@@ -53,7 +55,7 @@ class JSConfigHelper {
protected CapabilitiesManager $capabilitiesManager,
protected IInitialStateService $initialStateService,
protected IProvider $tokenProvider,
- protected FilenameValidator $filenameValidator,
+ protected FilenameValidator $filenameValidator,
) {
}
@@ -154,8 +156,8 @@ class JSConfigHelper {
'session_lifetime' => min($this->config->getSystemValue('session_lifetime', $this->iniWrapper->getNumeric('session.gc_maxlifetime')), $this->iniWrapper->getNumeric('session.gc_maxlifetime')),
'sharing.maxAutocompleteResults' => max(0, $this->config->getSystemValueInt('sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT)),
'sharing.minSearchStringLength' => $this->config->getSystemValueInt('sharing.minSearchStringLength', 0),
- 'version' => implode('.', Util::getVersion()),
- 'versionstring' => \OC_Util::getVersionString(),
+ 'version' => implode('.', $this->serverVersion->getVersion()),
+ 'versionstring' => $this->serverVersion->getVersionString(),
'enable_non-accessible_features' => $this->config->getSystemValueBool('enable_non-accessible_features', true),
];
diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php
index 6c7cec90740..c21df495b5b 100644
--- a/lib/private/TemplateLayout.php
+++ b/lib/private/TemplateLayout.php
@@ -25,6 +25,7 @@ use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUserSession;
use OCP\L10N\IFactory;
+use OCP\ServerVersion;
use OCP\Support\Subscription\IRegistry;
use OCP\Util;
@@ -218,6 +219,7 @@ class TemplateLayout extends \OC_Template {
// this is on purpose outside of the if statement below so that the initial state is prefilled (done in the getConfig() call)
// see https://github.com/nextcloud/server/pull/22636 for details
$jsConfigHelper = new JSConfigHelper(
+ \OCP\Server::get(ServerVersion::class),
\OCP\Util::getL10N('lib'),
\OCP\Server::get(Defaults::class),
\OC::$server->getAppManager(),
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index 2ea680efcf5..c4631f2c7d3 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -31,6 +31,7 @@ use OCP\HintException;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\ILogger;
+use OCP\ServerVersion;
use OCP\Util;
use Psr\Log\LoggerInterface;
@@ -53,6 +54,7 @@ class Updater extends BasicEmitter {
];
public function __construct(
+ private ServerVersion $serverVersion,
private IConfig $config,
private IAppConfig $appConfig,
private Checker $checker,
@@ -82,14 +84,14 @@ class Updater extends BasicEmitter {
}
// Clear CAN_INSTALL file if not on git
- if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir . '/CAN_INSTALL')) {
+ if ($this->serverVersion->getChannel() !== 'git' && is_file(\OC::$configDir . '/CAN_INSTALL')) {
if (!unlink(\OC::$configDir . '/CAN_INSTALL')) {
$this->log->error('Could not cleanup CAN_INSTALL from your config folder. Please remove this file manually.');
}
}
$installedVersion = $this->config->getSystemValueString('version', '0.0.0');
- $currentVersion = implode('.', \OCP\Util::getVersion());
+ $currentVersion = implode('.', $this->serverVersion->getVersion());
$this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, ['app' => 'core']);
diff --git a/lib/private/Updater/VersionCheck.php b/lib/private/Updater/VersionCheck.php
index cc5ff63379c..53bfc0d5d5f 100644
--- a/lib/private/Updater/VersionCheck.php
+++ b/lib/private/Updater/VersionCheck.php
@@ -11,12 +11,14 @@ use OCP\Http\Client\IClientService;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IUserManager;
+use OCP\ServerVersion;
use OCP\Support\Subscription\IRegistry;
use OCP\Util;
use Psr\Log\LoggerInterface;
class VersionCheck {
public function __construct(
+ private ServerVersion $serverVersion,
private IClientService $clientService,
private IConfig $config,
private IAppConfig $appConfig,
@@ -54,9 +56,9 @@ class VersionCheck {
$version = Util::getVersion();
$version['installed'] = $this->config->getAppValue('core', 'installedat');
$version['updated'] = $this->appConfig->getValueInt('core', 'lastupdatedat');
- $version['updatechannel'] = \OC_Util::getChannel();
+ $version['updatechannel'] = $this->serverVersion->getChannel();
$version['edition'] = '';
- $version['build'] = \OC_Util::getBuild();
+ $version['build'] = $this->serverVersion->getBuild();
$version['php_major'] = PHP_MAJOR_VERSION;
$version['php_minor'] = PHP_MINOR_VERSION;
$version['php_release'] = PHP_RELEASE_VERSION;
diff --git a/lib/private/legacy/OC_Defaults.php b/lib/private/legacy/OC_Defaults.php
index cc0ac687ccc..f7015a1863a 100644
--- a/lib/private/legacy/OC_Defaults.php
+++ b/lib/private/legacy/OC_Defaults.php
@@ -6,6 +6,10 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
+use OCP\IConfig;
+use OCP\Server;
+use OCP\ServerVersion;
+
class OC_Defaults {
private $theme;
@@ -27,7 +31,8 @@ class OC_Defaults {
private $defaultProductName;
public function __construct() {
- $config = \OC::$server->getConfig();
+ $config = Server::get(IConfig::class);
+ $serverVersion = Server::get(ServerVersion::class);
$this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */
$this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */
@@ -39,7 +44,7 @@ class OC_Defaults {
$this->defaultAndroidClientUrl = $config->getSystemValue('customclient_android', 'https://play.google.com/store/apps/details?id=com.nextcloud.client');
$this->defaultFDroidClientUrl = $config->getSystemValue('customclient_fdroid', 'https://f-droid.org/packages/com.nextcloud.client/');
$this->defaultDocBaseUrl = 'https://docs.nextcloud.com';
- $this->defaultDocVersion = \OC_Util::getVersion()[0]; // used to generate doc links
+ $this->defaultDocVersion = $serverVersion->getMajorVersion(); // used to generate doc links
$this->defaultColorBackground = '#00679e';
$this->defaultColorPrimary = '#00679e';
$this->defaultTextColorPrimary = '#ffffff';
diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php
index c390b7727e9..7b41f797e32 100644
--- a/lib/private/legacy/OC_Util.php
+++ b/lib/private/legacy/OC_Util.php
@@ -216,76 +216,6 @@ class OC_Util {
}
/**
- * get the current installed version of ownCloud
- *
- * @return array
- */
- public static function getVersion() {
- OC_Util::loadVersion();
- return self::$versionCache['OC_Version'];
- }
-
- /**
- * get the current installed version string of ownCloud
- *
- * @return string
- */
- public static function getVersionString() {
- OC_Util::loadVersion();
- return self::$versionCache['OC_VersionString'];
- }
-
- /**
- * @deprecated 11.0.0 the value is of no use anymore
- * @return string
- */
- public static function getEditionString() {
- return '';
- }
-
- /**
- * @description get the update channel of the current installed of ownCloud.
- * @return string
- */
- public static function getChannel() {
- OC_Util::loadVersion();
- return \OC::$server->getConfig()->getSystemValueString('updater.release.channel', self::$versionCache['OC_Channel']);
- }
-
- /**
- * @description get the build number of the current installed of ownCloud.
- * @return string
- */
- public static function getBuild() {
- OC_Util::loadVersion();
- return self::$versionCache['OC_Build'];
- }
-
- /**
- * @description load the version.php into the session as cache
- * @suppress PhanUndeclaredVariable
- */
- private static function loadVersion() {
- if (self::$versionCache !== null) {
- return;
- }
-
- $timestamp = filemtime(OC::$SERVERROOT . '/version.php');
- require OC::$SERVERROOT . '/version.php';
- /** @var int $timestamp */
- self::$versionCache['OC_Version_Timestamp'] = $timestamp;
- /** @var string $OC_Version */
- self::$versionCache['OC_Version'] = $OC_Version;
- /** @var string $OC_VersionString */
- self::$versionCache['OC_VersionString'] = $OC_VersionString;
- /** @var string $OC_Build */
- self::$versionCache['OC_Build'] = $OC_Build;
-
- /** @var string $OC_Channel */
- self::$versionCache['OC_Channel'] = $OC_Channel;
- }
-
- /**
* generates a path for JS/CSS files. If no application is provided it will create the path for core.
*
* @param string $application application to get the files from
@@ -1022,20 +952,6 @@ class OC_Util {
}
/**
- * A human readable string is generated based on version and build number
- *
- * @return string
- */
- public static function getHumanVersion() {
- $version = OC_Util::getVersionString();
- $build = OC_Util::getBuild();
- if (!empty($build) and OC_Util::getChannel() === 'daily') {
- $version .= ' Build:' . $build;
- }
- return $version;
- }
-
- /**
* Check whether the instance needs to perform an upgrade,
* either when the core version is higher or any app requires
* an upgrade.
diff --git a/lib/public/ServerVersion.php b/lib/public/ServerVersion.php
new file mode 100644
index 00000000000..637c34d3619
--- /dev/null
+++ b/lib/public/ServerVersion.php
@@ -0,0 +1,102 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP;
+
+/**
+ * @since 31.0.0
+ */
+class ServerVersion {
+
+ private array $version;
+ private string $versionString;
+ private string $build;
+ /** @var 'beta'|'stable'|'enterprise'|'git' */
+ private string $channel;
+
+ /**
+ * @since 31.0.0
+ */
+ public function __construct() {
+ $versionFile = __DIR__ . '/../../version.php';
+ require $versionFile;
+
+ /** @var int[] $OC_Version */
+ $this->version = $OC_Version;
+ /** @var string $OC_VersionString */
+ $this->versionString = $OC_VersionString;
+ /** @var string $OC_Build */
+ $this->build = $OC_Build;
+ /** @var string $OC_Channel */
+ $this->channel = $OC_Channel;
+ }
+
+ /**
+ * @since 31.0.0
+ */
+ public function getMajorVersion(): int {
+ return $this->version[0];
+ }
+
+ /**
+ * @since 31.0.0
+ */
+ public function getMinorVersion(): int {
+ return $this->version[1];
+ }
+
+ /**
+ * @since 31.0.0
+ */
+ public function getPatchVersion(): int {
+ return $this->version[2];
+ }
+
+ /**
+ * @since 31.0.0
+ */
+ public function getVersion(): array {
+ return $this->version;
+ }
+
+ /**
+ * @since 31.0.0
+ */
+ public function getVersionString(): string {
+ return $this->versionString;
+ }
+
+ /**
+ * @psalm-return 'beta'|'stable'|'enterprise'|'git'
+ * @since 31.0.0
+ */
+ public function getChannel(): string {
+ return $this->channel;
+ }
+
+ /**
+ * @since 31.0.0
+ */
+ public function getBuild(): string {
+ return $this->build;
+ }
+
+ /**
+ * @since 31.0.0
+ */
+ public function getHumanVersion(): string {
+ $version = $this->getVersionString();
+ $build = $this->getBuild();
+ if (!empty($build) && $this->getChannel() === 'daily') {
+ $version .= ' Build:' . $build;
+ }
+ return $version;
+
+ }
+}
diff --git a/lib/public/Util.php b/lib/public/Util.php
index 520e4616de5..28da91c9a0f 100644
--- a/lib/public/Util.php
+++ b/lib/public/Util.php
@@ -35,9 +35,10 @@ class Util {
* get the current installed version of Nextcloud
* @return array
* @since 4.0.0
+ * @deprecated 31.0.0 Use \OCP\ServerVersion::getVersion
*/
public static function getVersion() {
- return \OC_Util::getVersion();
+ return Server::get(ServerVersion::class)->getVersion();
}
/**
@@ -46,7 +47,7 @@ class Util {
public static function hasExtendedSupport(): bool {
try {
/** @var \OCP\Support\Subscription\IRegistry */
- $subscriptionRegistry = \OCP\Server::get(\OCP\Support\Subscription\IRegistry::class);
+ $subscriptionRegistry = Server::get(\OCP\Support\Subscription\IRegistry::class);
return $subscriptionRegistry->delegateHasExtendedSupport();
} catch (ContainerExceptionInterface $e) {
}
@@ -66,9 +67,10 @@ class Util {
* Get current update channel
* @return string
* @since 8.1.0
+ * @deprecated 31.0.0 Use \OCP\ServerVersion::getChannel
*/
public static function getChannel() {
- return \OC_Util::getChannel();
+ return \OCP\Server::get(ServerVersion::class)->getChannel();
}
/**
@@ -567,7 +569,7 @@ class Util {
if (!function_exists($functionName)) {
return false;
}
- $ini = \OCP\Server::get(IniGetWrapper::class);
+ $ini = Server::get(IniGetWrapper::class);
$disabled = explode(',', $ini->get('disable_functions') ?: '');
$disabled = array_map('trim', $disabled);
if (in_array($functionName, $disabled)) {