aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-05-12 15:15:23 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2025-05-12 18:06:41 +0200
commit957efe067051e5c299f886d6e1188f44a5cfe515 (patch)
tree2cf3b401119470f96aaf6328b55d0048b4dcd3da
parenta2eed985aa1266cb519d46c11f58e853eeb6c657 (diff)
downloadnextcloud-server-fix/update-notification-respect-config.tar.gz
nextcloud-server-fix/update-notification-respect-config.zip
fix(updatenotification): respect `updatechecker` configfix/update-notification-respect-config
If disabled: - Hide admin settings - Do not create Nextcloud server update notifications Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r--apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php7
-rw-r--r--apps/updatenotification/lib/Settings/Admin.php7
-rw-r--r--apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php18
-rw-r--r--apps/updatenotification/tests/Settings/AdminTest.php31
4 files changed, 56 insertions, 7 deletions
diff --git a/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php b/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
index f55bbe01dba..29bd5cb1426 100644
--- a/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
+++ b/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
@@ -64,9 +64,14 @@ class UpdateAvailableNotifications extends TimedJob {
}
/**
- * Check for ownCloud update
+ * Check for Nextcloud server update
*/
protected function checkCoreUpdate() {
+ if (!$this->config->getSystemValueBool('updatechecker', true)) {
+ // update checker is disabled so no core update check!
+ return;
+ }
+
if (\in_array($this->serverVersion->getChannel(), ['daily', 'git'], true)) {
// "These aren't the update channels you're looking for." - Ben Obi-Wan Kenobi
return;
diff --git a/apps/updatenotification/lib/Settings/Admin.php b/apps/updatenotification/lib/Settings/Admin.php
index a5f75dc99e6..dfd4de4180f 100644
--- a/apps/updatenotification/lib/Settings/Admin.php
+++ b/apps/updatenotification/lib/Settings/Admin.php
@@ -130,7 +130,12 @@ class Admin implements ISettings {
return $result;
}
- public function getSection(): string {
+ public function getSection(): ?string {
+ if (!$this->config->getSystemValueBool('updatechecker', true)) {
+ // update checker is disabled so we do not show the section at all
+ return null;
+ }
+
return 'overview';
}
diff --git a/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php
index c795c1dfee5..36c1d98f2dc 100644
--- a/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php
+++ b/apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php
@@ -25,7 +25,7 @@ use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class UpdateAvailableNotificationsTest extends TestCase {
- private ServerVersion $serverVersion;
+ private ServerVersion&MockObject $serverVersion;
private IConfig|MockObject $config;
private IManager|MockObject $notificationManager;
private IGroupManager|MockObject $groupManager;
@@ -96,13 +96,12 @@ class UpdateAvailableNotificationsTest extends TestCase {
$job->expects($this->once())
->method('checkAppUpdates');
- $this->config->expects($this->exactly(2))
+ $this->config->expects(self::exactly(2))
->method('getSystemValueBool')
->willReturnMap([
- ['has_internet_connection', true, true],
['debug', false, true],
+ ['has_internet_connection', true, true],
]);
-
self::invokePrivate($job, 'run', [null]);
}
@@ -117,7 +116,9 @@ class UpdateAvailableNotificationsTest extends TestCase {
$job->expects($this->never())
->method('checkAppUpdates');
- $this->config->method('getSystemValueBool')
+ $this->config
+ ->expects(self::once())
+ ->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(false);
@@ -212,6 +213,13 @@ class UpdateAvailableNotificationsTest extends TestCase {
->with('core', $version, $readableVersion);
}
+ $this->config->expects(self::any())
+ ->method('getSystemValueBool')
+ ->willReturnMap([
+ ['updatechecker', true, true],
+ ['has_internet_connection', true, true],
+ ]);
+
self::invokePrivate($job, 'checkCoreUpdate');
}
diff --git a/apps/updatenotification/tests/Settings/AdminTest.php b/apps/updatenotification/tests/Settings/AdminTest.php
index ed0b12ab10f..3652c8f9081 100644
--- a/apps/updatenotification/tests/Settings/AdminTest.php
+++ b/apps/updatenotification/tests/Settings/AdminTest.php
@@ -108,6 +108,11 @@ class AdminTest extends TestCase {
['updater.server.url', 'https://updates.nextcloud.com/updater_server/', 'https://updates.nextcloud.com/updater_server/'],
['upgrade.disable-web', false, false],
]);
+ $this->config
+ ->expects(self::any())
+ ->method('getSystemValueBool')
+ ->with('updatechecker', true)
+ ->willReturn(true);
$this->dateTimeFormatter
->expects($this->once())
->method('formatDateTime')
@@ -193,6 +198,11 @@ class AdminTest extends TestCase {
->with('core', 'lastupdatedat', 0)
->willReturn(12345);
$this->config
+ ->expects(self::any())
+ ->method('getSystemValueBool')
+ ->with('updatechecker', true)
+ ->willReturn(true);
+ $this->config
->expects($this->once())
->method('getAppValue')
->with('updatenotification', 'notify_groups', '["admin"]')
@@ -288,6 +298,11 @@ class AdminTest extends TestCase {
->with('core', 'lastupdatedat', 0)
->willReturn(12345);
$this->config
+ ->expects(self::any())
+ ->method('getSystemValueBool')
+ ->with('updatechecker', true)
+ ->willReturn(true);
+ $this->config
->expects($this->once())
->method('getAppValue')
->with('updatenotification', 'notify_groups', '["admin"]')
@@ -363,9 +378,25 @@ class AdminTest extends TestCase {
public function testGetSection(): void {
+ $this->config
+ ->expects(self::atLeastOnce())
+ ->method('getSystemValueBool')
+ ->with('updatechecker', true)
+ ->willReturn(true);
+
$this->assertSame('overview', $this->admin->getSection());
}
+ public function testGetSectionDisabled(): void {
+ $this->config
+ ->expects(self::atLeastOnce())
+ ->method('getSystemValueBool')
+ ->with('updatechecker', true)
+ ->willReturn(false);
+
+ $this->assertNull($this->admin->getSection());
+ }
+
public function testGetPriority(): void {
$this->assertSame(11, $this->admin->getPriority());
}