aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJulius Knorr <jus@bitgrid.net>2024-09-17 22:38:44 +0200
committerJulius Knorr <jus@bitgrid.net>2024-09-20 14:53:34 +0200
commit606241caebda2e01702c0d08adbc35ace8d01f13 (patch)
treeda9cc49d1079724a9192f89415c594b97db93aa9 /apps
parent7ff911665e7507a800e05fe9cd80e0304cd11dbc (diff)
downloadnextcloud-server-clean/version-ocp.tar.gz
nextcloud-server-clean/version-ocp.zip
chore(legacy): Introduce public version ct plass and drop version methods from OC_Utilclean/version-ocp
Signed-off-by: Julius Knorr <jus@bitgrid.net>
Diffstat (limited to 'apps')
-rw-r--r--apps/settings/lib/Settings/Admin/Overview.php16
-rw-r--r--apps/settings/templates/settings/admin/overview.php2
-rw-r--r--apps/theming/lib/Util.php21
-rw-r--r--apps/theming/tests/CapabilitiesTest.php3
-rw-r--r--apps/theming/tests/IconBuilderTest.php3
-rw-r--r--apps/theming/tests/Themes/DarkHighContrastThemeTest.php2
-rw-r--r--apps/theming/tests/Themes/DarkThemeTest.php2
-rw-r--r--apps/theming/tests/Themes/DefaultThemeTest.php2
-rw-r--r--apps/theming/tests/Themes/DyslexiaFontTest.php2
-rw-r--r--apps/theming/tests/Themes/HighContrastThemeTest.php2
-rw-r--r--apps/theming/tests/UtilTest.php3
-rw-r--r--apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php11
-rw-r--r--apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php8
-rw-r--r--apps/user_ldap/lib/Controller/ConfigAPIController.php5
14 files changed, 46 insertions, 36 deletions
diff --git a/apps/settings/lib/Settings/Admin/Overview.php b/apps/settings/lib/Settings/Admin/Overview.php
index d796f91f83d..83027326a35 100644
--- a/apps/settings/lib/Settings/Admin/Overview.php
+++ b/apps/settings/lib/Settings/Admin/Overview.php
@@ -8,18 +8,15 @@ namespace OCA\Settings\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IL10N;
+use OCP\ServerVersion;
use OCP\Settings\IDelegatedSettings;
class Overview implements IDelegatedSettings {
- /** @var IConfig */
- private $config;
-
- /** @var IL10N $l */
- private $l;
-
- public function __construct(IConfig $config, IL10N $l) {
- $this->config = $config;
- $this->l = $l;
+ public function __construct(
+ private ServerVersion $serverVersion,
+ private IConfig $config,
+ private IL10N $l,
+ ) {
}
/**
@@ -28,6 +25,7 @@ class Overview implements IDelegatedSettings {
public function getForm() {
$parameters = [
'checkForWorkingWellKnownSetup' => $this->config->getSystemValue('check_for_working_wellknown_setup', true),
+ 'version' => $this->serverVersion->getHumanVersion(),
];
return new TemplateResponse('settings', 'settings/admin/overview', $parameters, '');
diff --git a/apps/settings/templates/settings/admin/overview.php b/apps/settings/templates/settings/admin/overview.php
index 83eab572534..c6d3ffa40ba 100644
--- a/apps/settings/templates/settings/admin/overview.php
+++ b/apps/settings/templates/settings/admin/overview.php
@@ -57,5 +57,5 @@
<div id="version" class="section">
<!-- should be the last part, so Updater can follow if enabled (it has no heading therefore). -->
<h2><?php p($l->t('Version'));?></h2>
- <p><strong><a href="<?php print_unescaped($theme->getBaseUrl()); ?>" rel="noreferrer noopener" target="_blank">Nextcloud Hub 9</a> (<?php p(OC_Util::getHumanVersion()) ?>)</strong></p>
+ <p><strong><a href="<?php print_unescaped($theme->getBaseUrl()); ?>" rel="noreferrer noopener" target="_blank">Nextcloud Hub 9</a> (<?php p($_['version']) ?>)</strong></p>
</div>
diff --git a/apps/theming/lib/Util.php b/apps/theming/lib/Util.php
index 839ef1d0b46..fbb465505ac 100644
--- a/apps/theming/lib/Util.php
+++ b/apps/theming/lib/Util.php
@@ -13,19 +13,16 @@ use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\IConfig;
use OCP\IUserSession;
+use OCP\ServerVersion;
class Util {
-
- private IConfig $config;
- private IAppManager $appManager;
- private IAppData $appData;
- private ImageManager $imageManager;
-
- public function __construct(IConfig $config, IAppManager $appManager, IAppData $appData, ImageManager $imageManager) {
- $this->config = $config;
- $this->appManager = $appManager;
- $this->appData = $appData;
- $this->imageManager = $imageManager;
+ public function __construct(
+ private ServerVersion $serverVersion,
+ private IConfig $config,
+ private IAppManager $appManager,
+ private IAppData $appData,
+ private ImageManager $imageManager,
+ ) {
}
/**
@@ -311,7 +308,7 @@ class Util {
if (!is_null($user)) {
$userId = $user->getUID();
}
- $serverVersion = \OC_Util::getVersionString();
+ $serverVersion = $this->serverVersion->getVersionString();
$themingAppVersion = $this->appManager->getAppVersion('theming');
$userCacheBuster = '';
if ($userId) {
diff --git a/apps/theming/tests/CapabilitiesTest.php b/apps/theming/tests/CapabilitiesTest.php
index 277dd5b6a7a..1274be929ef 100644
--- a/apps/theming/tests/CapabilitiesTest.php
+++ b/apps/theming/tests/CapabilitiesTest.php
@@ -14,6 +14,7 @@ use OCP\Files\IAppData;
use OCP\IConfig;
use OCP\IURLGenerator;
use OCP\IUserSession;
+use OCP\ServerVersion;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -169,7 +170,7 @@ class CapabilitiesTest extends TestCase {
->method('getLogo')
->willReturn($logo);
- $util = new Util($this->config, $this->createMock(IAppManager::class), $this->createMock(IAppData::class), $this->createMock(ImageManager::class));
+ $util = new Util($this->createMock(ServerVersion::class), $this->config, $this->createMock(IAppManager::class), $this->createMock(IAppData::class), $this->createMock(ImageManager::class));
$this->util->expects($this->exactly(3))
->method('elementColor')
->with($color)
diff --git a/apps/theming/tests/IconBuilderTest.php b/apps/theming/tests/IconBuilderTest.php
index bef48448bfa..ec7bd8bcc55 100644
--- a/apps/theming/tests/IconBuilderTest.php
+++ b/apps/theming/tests/IconBuilderTest.php
@@ -13,6 +13,7 @@ use OCA\Theming\Util;
use OCP\App\IAppManager;
use OCP\Files\NotFoundException;
use OCP\IConfig;
+use OCP\ServerVersion;
use PHPUnit\Framework\Error\Warning;
use Test\TestCase;
@@ -41,7 +42,7 @@ class IconBuilderTest extends TestCase {
$this->themingDefaults = $this->createMock(ThemingDefaults::class);
$this->appManager = $this->createMock(IAppManager::class);
$this->imageManager = $this->createMock(ImageManager::class);
- $this->util = new Util($this->config, $this->appManager, $this->appData, $this->imageManager);
+ $this->util = new Util($this->createMock(ServerVersion::class), $this->config, $this->appManager, $this->appData, $this->imageManager);
$this->iconBuilder = new IconBuilder($this->themingDefaults, $this->util, $this->imageManager);
}
diff --git a/apps/theming/tests/Themes/DarkHighContrastThemeTest.php b/apps/theming/tests/Themes/DarkHighContrastThemeTest.php
index 63fb2bf414d..16f7e86d217 100644
--- a/apps/theming/tests/Themes/DarkHighContrastThemeTest.php
+++ b/apps/theming/tests/Themes/DarkHighContrastThemeTest.php
@@ -18,6 +18,7 @@ use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUserSession;
+use OCP\ServerVersion;
use PHPUnit\Framework\MockObject\MockObject;
class DarkHighContrastThemeTest extends AccessibleThemeTestCase {
@@ -49,6 +50,7 @@ class DarkHighContrastThemeTest extends AccessibleThemeTestCase {
$this->appManager = $this->createMock(IAppManager::class);
$this->util = new Util(
+ $this->createMock(ServerVersion::class),
$this->config,
$this->appManager,
$this->createMock(IAppData::class),
diff --git a/apps/theming/tests/Themes/DarkThemeTest.php b/apps/theming/tests/Themes/DarkThemeTest.php
index f53028d3a63..ea570adf21d 100644
--- a/apps/theming/tests/Themes/DarkThemeTest.php
+++ b/apps/theming/tests/Themes/DarkThemeTest.php
@@ -18,6 +18,7 @@ use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUserSession;
+use OCP\ServerVersion;
use PHPUnit\Framework\MockObject\MockObject;
class DarkThemeTest extends AccessibleThemeTestCase {
@@ -46,6 +47,7 @@ class DarkThemeTest extends AccessibleThemeTestCase {
$this->appManager = $this->createMock(IAppManager::class);
$this->util = new Util(
+ $this->createMock(ServerVersion::class),
$this->config,
$this->appManager,
$this->createMock(IAppData::class),
diff --git a/apps/theming/tests/Themes/DefaultThemeTest.php b/apps/theming/tests/Themes/DefaultThemeTest.php
index db6a5bf1cfc..b463cf4567c 100644
--- a/apps/theming/tests/Themes/DefaultThemeTest.php
+++ b/apps/theming/tests/Themes/DefaultThemeTest.php
@@ -18,6 +18,7 @@ use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUserSession;
+use OCP\ServerVersion;
use PHPUnit\Framework\MockObject\MockObject;
class DefaultThemeTest extends AccessibleThemeTestCase {
@@ -46,6 +47,7 @@ class DefaultThemeTest extends AccessibleThemeTestCase {
$this->appManager = $this->createMock(IAppManager::class);
$this->util = new Util(
+ $this->createMock(ServerVersion::class),
$this->config,
$this->appManager,
$this->createMock(IAppData::class),
diff --git a/apps/theming/tests/Themes/DyslexiaFontTest.php b/apps/theming/tests/Themes/DyslexiaFontTest.php
index 53505f4bd03..a022ee40114 100644
--- a/apps/theming/tests/Themes/DyslexiaFontTest.php
+++ b/apps/theming/tests/Themes/DyslexiaFontTest.php
@@ -19,6 +19,7 @@ use OCP\IL10N;
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUserSession;
+use OCP\ServerVersion;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -49,6 +50,7 @@ class DyslexiaFontTest extends TestCase {
$this->appManager = $this->createMock(IAppManager::class);
$util = new Util(
+ $this->createMock(ServerVersion::class),
$this->config,
$this->appManager,
$this->createMock(IAppData::class),
diff --git a/apps/theming/tests/Themes/HighContrastThemeTest.php b/apps/theming/tests/Themes/HighContrastThemeTest.php
index 603bf08a0ee..71576caf841 100644
--- a/apps/theming/tests/Themes/HighContrastThemeTest.php
+++ b/apps/theming/tests/Themes/HighContrastThemeTest.php
@@ -18,6 +18,7 @@ use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUserSession;
+use OCP\ServerVersion;
use PHPUnit\Framework\MockObject\MockObject;
class HighContrastThemeTest extends AccessibleThemeTestCase {
@@ -49,6 +50,7 @@ class HighContrastThemeTest extends AccessibleThemeTestCase {
$this->appManager = $this->createMock(IAppManager::class);
$this->util = new Util(
+ $this->createMock(ServerVersion::class),
$this->config,
$this->appManager,
$this->createMock(IAppData::class),
diff --git a/apps/theming/tests/UtilTest.php b/apps/theming/tests/UtilTest.php
index ba160684b7a..9a05c77a274 100644
--- a/apps/theming/tests/UtilTest.php
+++ b/apps/theming/tests/UtilTest.php
@@ -13,6 +13,7 @@ use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\IConfig;
+use OCP\ServerVersion;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -30,7 +31,7 @@ class UtilTest extends TestCase {
$this->appData = $this->createMock(IAppData::class);
$this->appManager = \OCP\Server::get(IAppManager::class);
$this->imageManager = $this->createMock(ImageManager::class);
- $this->util = new Util($this->config, $this->appManager, $this->appData, $this->imageManager);
+ $this->util = new Util($this->createMock(ServerVersion::class), $this->config, $this->appManager, $this->appData, $this->imageManager);
}
public function dataColorContrast() {
diff --git a/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php b/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
index dd6497c7e48..30786f5e12d 100644
--- a/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
+++ b/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
@@ -18,6 +18,7 @@ use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\Notification\IManager;
+use OCP\ServerVersion;
class UpdateAvailableNotifications extends TimedJob {
protected $connectionNotifications = [3, 7, 14, 30];
@@ -27,6 +28,7 @@ class UpdateAvailableNotifications extends TimedJob {
public function __construct(
ITimeFactory $timeFactory,
+ protected ServerVersion $serverVersion,
protected IConfig $config,
protected IAppConfig $appConfig,
protected IManager $notificationManager,
@@ -64,7 +66,7 @@ class UpdateAvailableNotifications extends TimedJob {
* Check for ownCloud update
*/
protected function checkCoreUpdate() {
- if (\in_array($this->getChannel(), ['daily', 'git'], true)) {
+ if (\in_array($this->serverVersion->getChannel(), ['daily', 'git'], true)) {
// "These aren't the update channels you're looking for." - Ben Obi-Wan Kenobi
return;
}
@@ -221,13 +223,6 @@ class UpdateAvailableNotifications extends TimedJob {
}
/**
- * @return string
- */
- protected function getChannel(): string {
- return \OC_Util::getChannel();
- }
-
- /**
* @param string $app
* @return string|false
*/
diff --git a/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php
index 3ebeb3d805d..61bacf9e0ac 100644
--- a/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php
+++ b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php
@@ -20,10 +20,12 @@ use OCP\IGroupManager;
use OCP\IUser;
use OCP\Notification\IManager;
use OCP\Notification\INotification;
+use OCP\ServerVersion;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class UpdateAvailableNotificationsTest extends TestCase {
+ private ServerVersion $serverVersion;
private IConfig|MockObject $config;
private IManager|MockObject $notificationManager;
private IGroupManager|MockObject $groupManager;
@@ -36,6 +38,7 @@ class UpdateAvailableNotificationsTest extends TestCase {
protected function setUp(): void {
parent::setUp();
+ $this->serverVersion = $this->createMock(ServerVersion::class);
$this->config = $this->createMock(IConfig::class);
$this->appConfig = $this->createMock(IAppConfig::class);
$this->notificationManager = $this->createMock(IManager::class);
@@ -54,6 +57,7 @@ class UpdateAvailableNotificationsTest extends TestCase {
if (empty($methods)) {
return new UpdateAvailableNotifications(
$this->timeFactory,
+ $this->serverVersion,
$this->config,
$this->appConfig,
$this->notificationManager,
@@ -67,6 +71,7 @@ class UpdateAvailableNotificationsTest extends TestCase {
return $this->getMockBuilder(UpdateAvailableNotifications::class)
->setConstructorArgs([
$this->timeFactory,
+ $this->serverVersion,
$this->config,
$this->appConfig,
$this->notificationManager,
@@ -158,13 +163,12 @@ class UpdateAvailableNotificationsTest extends TestCase {
*/
public function testCheckCoreUpdate(string $channel, $versionCheck, $version, $readableVersion, $errorDays): void {
$job = $this->getJob([
- 'getChannel',
'createNotifications',
'clearErrorNotifications',
'sendErrorNotifications',
]);
- $job->expects($this->once())
+ $this->serverVersion->expects($this->once())
->method('getChannel')
->willReturn($channel);
diff --git a/apps/user_ldap/lib/Controller/ConfigAPIController.php b/apps/user_ldap/lib/Controller/ConfigAPIController.php
index f4f55217ef1..8ce2486c153 100644
--- a/apps/user_ldap/lib/Controller/ConfigAPIController.php
+++ b/apps/user_ldap/lib/Controller/ConfigAPIController.php
@@ -21,6 +21,7 @@ use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\IRequest;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\ServerVersion;
use Psr\Log\LoggerInterface;
class ConfigAPIController extends OCSController {
@@ -31,6 +32,7 @@ class ConfigAPIController extends OCSController {
IUserSession $userSession,
IUserManager $userManager,
Manager $keyManager,
+ ServerVersion $serverVersion,
private Helper $ldapHelper,
private LoggerInterface $logger,
private ConnectionFactory $connectionFactory,
@@ -41,7 +43,8 @@ class ConfigAPIController extends OCSController {
$capabilitiesManager,
$userSession,
$userManager,
- $keyManager
+ $keyManager,
+ $serverVersion,
);
}