Skip to content

Commit 606241c

Browse files
committed
chore(legacy): Introduce public version ct plass and drop version methods from OC_Util
Signed-off-by: Julius Knorr <[email protected]>
1 parent 7ff9116 commit 606241c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+285
-264
lines changed

apps/settings/lib/Settings/Admin/Overview.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@
88
use OCP\AppFramework\Http\TemplateResponse;
99
use OCP\IConfig;
1010
use OCP\IL10N;
11+
use OCP\ServerVersion;
1112
use OCP\Settings\IDelegatedSettings;
1213

1314
class Overview implements IDelegatedSettings {
14-
/** @var IConfig */
15-
private $config;
16-
17-
/** @var IL10N $l */
18-
private $l;
19-
20-
public function __construct(IConfig $config, IL10N $l) {
21-
$this->config = $config;
22-
$this->l = $l;
15+
public function __construct(
16+
private ServerVersion $serverVersion,
17+
private IConfig $config,
18+
private IL10N $l,
19+
) {
2320
}
2421

2522
/**
@@ -28,6 +25,7 @@ public function __construct(IConfig $config, IL10N $l) {
2825
public function getForm() {
2926
$parameters = [
3027
'checkForWorkingWellKnownSetup' => $this->config->getSystemValue('check_for_working_wellknown_setup', true),
28+
'version' => $this->serverVersion->getHumanVersion(),
3129
];
3230

3331
return new TemplateResponse('settings', 'settings/admin/overview', $parameters, '');

apps/settings/templates/settings/admin/overview.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ class="icon-info"
5757
<div id="version" class="section">
5858
<!-- should be the last part, so Updater can follow if enabled (it has no heading therefore). -->
5959
<h2><?php p($l->t('Version'));?></h2>
60-
<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>
60+
<p><strong><a href="<?php print_unescaped($theme->getBaseUrl()); ?>" rel="noreferrer noopener" target="_blank">Nextcloud Hub 9</a> (<?php p($_['version']) ?>)</strong></p>
6161
</div>

apps/theming/lib/Util.php

+9-12
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,16 @@
1313
use OCP\Files\SimpleFS\ISimpleFile;
1414
use OCP\IConfig;
1515
use OCP\IUserSession;
16+
use OCP\ServerVersion;
1617

1718
class Util {
18-
19-
private IConfig $config;
20-
private IAppManager $appManager;
21-
private IAppData $appData;
22-
private ImageManager $imageManager;
23-
24-
public function __construct(IConfig $config, IAppManager $appManager, IAppData $appData, ImageManager $imageManager) {
25-
$this->config = $config;
26-
$this->appManager = $appManager;
27-
$this->appData = $appData;
28-
$this->imageManager = $imageManager;
19+
public function __construct(
20+
private ServerVersion $serverVersion,
21+
private IConfig $config,
22+
private IAppManager $appManager,
23+
private IAppData $appData,
24+
private ImageManager $imageManager,
25+
) {
2926
}
3027

3128
/**
@@ -311,7 +308,7 @@ public function getCacheBuster(): string {
311308
if (!is_null($user)) {
312309
$userId = $user->getUID();
313310
}
314-
$serverVersion = \OC_Util::getVersionString();
311+
$serverVersion = $this->serverVersion->getVersionString();
315312
$themingAppVersion = $this->appManager->getAppVersion('theming');
316313
$userCacheBuster = '';
317314
if ($userId) {

apps/theming/tests/CapabilitiesTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OCP\IConfig;
1515
use OCP\IURLGenerator;
1616
use OCP\IUserSession;
17+
use OCP\ServerVersion;
1718
use PHPUnit\Framework\MockObject\MockObject;
1819
use Test\TestCase;
1920

@@ -169,7 +170,7 @@ public function testGetCapabilities($name, $url, $slogan, $color, $textColor, $l
169170
->method('getLogo')
170171
->willReturn($logo);
171172

172-
$util = new Util($this->config, $this->createMock(IAppManager::class), $this->createMock(IAppData::class), $this->createMock(ImageManager::class));
173+
$util = new Util($this->createMock(ServerVersion::class), $this->config, $this->createMock(IAppManager::class), $this->createMock(IAppData::class), $this->createMock(ImageManager::class));
173174
$this->util->expects($this->exactly(3))
174175
->method('elementColor')
175176
->with($color)

apps/theming/tests/IconBuilderTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use OCP\App\IAppManager;
1414
use OCP\Files\NotFoundException;
1515
use OCP\IConfig;
16+
use OCP\ServerVersion;
1617
use PHPUnit\Framework\Error\Warning;
1718
use Test\TestCase;
1819

@@ -41,7 +42,7 @@ protected function setUp(): void {
4142
$this->themingDefaults = $this->createMock(ThemingDefaults::class);
4243
$this->appManager = $this->createMock(IAppManager::class);
4344
$this->imageManager = $this->createMock(ImageManager::class);
44-
$this->util = new Util($this->config, $this->appManager, $this->appData, $this->imageManager);
45+
$this->util = new Util($this->createMock(ServerVersion::class), $this->config, $this->appManager, $this->appData, $this->imageManager);
4546
$this->iconBuilder = new IconBuilder($this->themingDefaults, $this->util, $this->imageManager);
4647
}
4748

apps/theming/tests/Themes/DarkHighContrastThemeTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCP\IL10N;
1919
use OCP\IURLGenerator;
2020
use OCP\IUserSession;
21+
use OCP\ServerVersion;
2122
use PHPUnit\Framework\MockObject\MockObject;
2223

2324
class DarkHighContrastThemeTest extends AccessibleThemeTestCase {
@@ -49,6 +50,7 @@ protected function setUp(): void {
4950
$this->appManager = $this->createMock(IAppManager::class);
5051

5152
$this->util = new Util(
53+
$this->createMock(ServerVersion::class),
5254
$this->config,
5355
$this->appManager,
5456
$this->createMock(IAppData::class),

apps/theming/tests/Themes/DarkThemeTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCP\IL10N;
1919
use OCP\IURLGenerator;
2020
use OCP\IUserSession;
21+
use OCP\ServerVersion;
2122
use PHPUnit\Framework\MockObject\MockObject;
2223

2324
class DarkThemeTest extends AccessibleThemeTestCase {
@@ -46,6 +47,7 @@ protected function setUp(): void {
4647
$this->appManager = $this->createMock(IAppManager::class);
4748

4849
$this->util = new Util(
50+
$this->createMock(ServerVersion::class),
4951
$this->config,
5052
$this->appManager,
5153
$this->createMock(IAppData::class),

apps/theming/tests/Themes/DefaultThemeTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCP\IL10N;
1919
use OCP\IURLGenerator;
2020
use OCP\IUserSession;
21+
use OCP\ServerVersion;
2122
use PHPUnit\Framework\MockObject\MockObject;
2223

2324
class DefaultThemeTest extends AccessibleThemeTestCase {
@@ -46,6 +47,7 @@ protected function setUp(): void {
4647
$this->appManager = $this->createMock(IAppManager::class);
4748

4849
$this->util = new Util(
50+
$this->createMock(ServerVersion::class),
4951
$this->config,
5052
$this->appManager,
5153
$this->createMock(IAppData::class),

apps/theming/tests/Themes/DyslexiaFontTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use OCP\IRequest;
2020
use OCP\IURLGenerator;
2121
use OCP\IUserSession;
22+
use OCP\ServerVersion;
2223
use PHPUnit\Framework\MockObject\MockObject;
2324
use Test\TestCase;
2425

@@ -49,6 +50,7 @@ protected function setUp(): void {
4950
$this->appManager = $this->createMock(IAppManager::class);
5051

5152
$util = new Util(
53+
$this->createMock(ServerVersion::class),
5254
$this->config,
5355
$this->appManager,
5456
$this->createMock(IAppData::class),

apps/theming/tests/Themes/HighContrastThemeTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCP\IL10N;
1919
use OCP\IURLGenerator;
2020
use OCP\IUserSession;
21+
use OCP\ServerVersion;
2122
use PHPUnit\Framework\MockObject\MockObject;
2223

2324
class HighContrastThemeTest extends AccessibleThemeTestCase {
@@ -49,6 +50,7 @@ protected function setUp(): void {
4950
$this->appManager = $this->createMock(IAppManager::class);
5051

5152
$this->util = new Util(
53+
$this->createMock(ServerVersion::class),
5254
$this->config,
5355
$this->appManager,
5456
$this->createMock(IAppData::class),

apps/theming/tests/UtilTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use OCP\Files\SimpleFS\ISimpleFile;
1414
use OCP\Files\SimpleFS\ISimpleFolder;
1515
use OCP\IConfig;
16+
use OCP\ServerVersion;
1617
use PHPUnit\Framework\MockObject\MockObject;
1718
use Test\TestCase;
1819

@@ -30,7 +31,7 @@ protected function setUp(): void {
3031
$this->appData = $this->createMock(IAppData::class);
3132
$this->appManager = \OCP\Server::get(IAppManager::class);
3233
$this->imageManager = $this->createMock(ImageManager::class);
33-
$this->util = new Util($this->config, $this->appManager, $this->appData, $this->imageManager);
34+
$this->util = new Util($this->createMock(ServerVersion::class), $this->config, $this->appManager, $this->appData, $this->imageManager);
3435
}
3536

3637
public function dataColorContrast() {

apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCP\IGroup;
1919
use OCP\IGroupManager;
2020
use OCP\Notification\IManager;
21+
use OCP\ServerVersion;
2122

2223
class UpdateAvailableNotifications extends TimedJob {
2324
protected $connectionNotifications = [3, 7, 14, 30];
@@ -27,6 +28,7 @@ class UpdateAvailableNotifications extends TimedJob {
2728

2829
public function __construct(
2930
ITimeFactory $timeFactory,
31+
protected ServerVersion $serverVersion,
3032
protected IConfig $config,
3133
protected IAppConfig $appConfig,
3234
protected IManager $notificationManager,
@@ -64,7 +66,7 @@ protected function run($argument) {
6466
* Check for ownCloud update
6567
*/
6668
protected function checkCoreUpdate() {
67-
if (\in_array($this->getChannel(), ['daily', 'git'], true)) {
69+
if (\in_array($this->serverVersion->getChannel(), ['daily', 'git'], true)) {
6870
// "These aren't the update channels you're looking for." - Ben Obi-Wan Kenobi
6971
return;
7072
}
@@ -220,13 +222,6 @@ protected function deleteOutdatedNotifications($app, $version) {
220222
$this->notificationManager->markProcessed($notification);
221223
}
222224

223-
/**
224-
* @return string
225-
*/
226-
protected function getChannel(): string {
227-
return \OC_Util::getChannel();
228-
}
229-
230225
/**
231226
* @param string $app
232227
* @return string|false

apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
use OCP\IUser;
2121
use OCP\Notification\IManager;
2222
use OCP\Notification\INotification;
23+
use OCP\ServerVersion;
2324
use PHPUnit\Framework\MockObject\MockObject;
2425
use Test\TestCase;
2526

2627
class UpdateAvailableNotificationsTest extends TestCase {
28+
private ServerVersion $serverVersion;
2729
private IConfig|MockObject $config;
2830
private IManager|MockObject $notificationManager;
2931
private IGroupManager|MockObject $groupManager;
@@ -36,6 +38,7 @@ class UpdateAvailableNotificationsTest extends TestCase {
3638
protected function setUp(): void {
3739
parent::setUp();
3840

41+
$this->serverVersion = $this->createMock(ServerVersion::class);
3942
$this->config = $this->createMock(IConfig::class);
4043
$this->appConfig = $this->createMock(IAppConfig::class);
4144
$this->notificationManager = $this->createMock(IManager::class);
@@ -54,6 +57,7 @@ protected function getJob(array $methods = []) {
5457
if (empty($methods)) {
5558
return new UpdateAvailableNotifications(
5659
$this->timeFactory,
60+
$this->serverVersion,
5761
$this->config,
5862
$this->appConfig,
5963
$this->notificationManager,
@@ -67,6 +71,7 @@ protected function getJob(array $methods = []) {
6771
return $this->getMockBuilder(UpdateAvailableNotifications::class)
6872
->setConstructorArgs([
6973
$this->timeFactory,
74+
$this->serverVersion,
7075
$this->config,
7176
$this->appConfig,
7277
$this->notificationManager,
@@ -158,13 +163,12 @@ public function dataCheckCoreUpdate(): array {
158163
*/
159164
public function testCheckCoreUpdate(string $channel, $versionCheck, $version, $readableVersion, $errorDays): void {
160165
$job = $this->getJob([
161-
'getChannel',
162166
'createNotifications',
163167
'clearErrorNotifications',
164168
'sendErrorNotifications',
165169
]);
166170

167-
$job->expects($this->once())
171+
$this->serverVersion->expects($this->once())
168172
->method('getChannel')
169173
->willReturn($channel);
170174

apps/user_ldap/lib/Controller/ConfigAPIController.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use OCP\IRequest;
2222
use OCP\IUserManager;
2323
use OCP\IUserSession;
24+
use OCP\ServerVersion;
2425
use Psr\Log\LoggerInterface;
2526

2627
class ConfigAPIController extends OCSController {
@@ -31,6 +32,7 @@ public function __construct(
3132
IUserSession $userSession,
3233
IUserManager $userManager,
3334
Manager $keyManager,
35+
ServerVersion $serverVersion,
3436
private Helper $ldapHelper,
3537
private LoggerInterface $logger,
3638
private ConnectionFactory $connectionFactory,
@@ -41,7 +43,8 @@ public function __construct(
4143
$capabilitiesManager,
4244
$userSession,
4345
$userManager,
44-
$keyManager
46+
$keyManager,
47+
$serverVersion,
4548
);
4649
}
4750

core/Command/Status.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
*/
88
namespace OC\Core\Command;
99

10-
use OC_Util;
1110
use OCP\Defaults;
1211
use OCP\IConfig;
12+
use OCP\ServerVersion;
1313
use OCP\Util;
1414
use Symfony\Component\Console\Input\InputInterface;
1515
use Symfony\Component\Console\Input\InputOption;
@@ -19,6 +19,7 @@ class Status extends Base {
1919
public function __construct(
2020
private IConfig $config,
2121
private Defaults $themingDefaults,
22+
private ServerVersion $serverVersion,
2223
) {
2324
parent::__construct('status');
2425
}
@@ -41,8 +42,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4142
$needUpgrade = Util::needUpgrade();
4243
$values = [
4344
'installed' => $this->config->getSystemValueBool('installed', false),
44-
'version' => implode('.', Util::getVersion()),
45-
'versionstring' => OC_Util::getVersionString(),
45+
'version' => implode('.', $this->serverVersion->getVersion()),
46+
'versionstring' => $this->serverVersion->getVersionString(),
4647
'edition' => '',
4748
'maintenance' => $maintenanceMode,
4849
'needsDbUpgrade' => $needUpgrade,

core/Controller/OCJSController.php

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use OCP\IURLGenerator;
2828
use OCP\IUserSession;
2929
use OCP\L10N\IFactory;
30+
use OCP\ServerVersion;
3031

3132
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
3233
class OCJSController extends Controller {
@@ -48,10 +49,12 @@ public function __construct(
4849
IInitialStateService $initialStateService,
4950
IProvider $tokenProvider,
5051
FilenameValidator $filenameValidator,
52+
ServerVersion $serverVersion,
5153
) {
5254
parent::__construct($appName, $request);
5355

5456
$this->helper = new JSConfigHelper(
57+
$serverVersion,
5558
$l10nFactory->get('lib'),
5659
$defaults,
5760
$appManager,

0 commit comments

Comments
 (0)