From fdd6da545dd7c7c03800828763763de465b9edbb Mon Sep 17 00:00:00 2001 From: Rello Date: Mon, 1 Jun 2026 15:13:29 +0200 Subject: [PATCH 1/2] Enterprise clients now receive stable only when: - They were manually upgraded beyond the enterprise release. - Stable is newer than the installed version. - Stable remains within the installed major version. Added regression coverage for 4.0.10 -> 33.0.2 -> 33.0.5, cross-major rejection, and already-current clients Signed-off-by: Rello --- src/Response.php | 11 ++++++- tests/unit/ResponseTest.php | 62 ++++++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/Response.php b/src/Response.php index c8d2208..574d029 100644 --- a/src/Response.php +++ b/src/Response.php @@ -115,7 +115,12 @@ private function getUpdateVersion() : array { if (version_compare($this->version, $enterprise['version']) === -1 || $isMacOs) { return $enterprise; } - return []; // do not fall back to stable in case there is no enterprise update + if (version_compare($this->version, $enterprise['version']) === 1 + && version_compare($this->version, $stable['version']) === -1 + && $this->hasSameMajorVersion($this->version, $stable['version'])) { + return $stable; + } + return []; // Otherwise do not fall back to stable when there is no enterprise update } if (version_compare($this->version, $stable['version']) == -1 || $isMacOs) { @@ -125,6 +130,10 @@ private function getUpdateVersion() : array { return []; } + private function hasSameMajorVersion(string $currentVersion, string $updateVersion): bool { + return explode('.', $currentVersion, 2)[0] === explode('.', $updateVersion, 2)[0]; + } + private function getLegacyChannel(): ?string { // Outdated platforms (Qt5 era): // - macOS < 11 diff --git a/tests/unit/ResponseTest.php b/tests/unit/ResponseTest.php index e9e55fd..cf8f3b7 100644 --- a/tests/unit/ResponseTest.php +++ b/tests/unit/ResponseTest.php @@ -140,6 +140,18 @@ public function updateDataProvider(): array $configThrottle = $config; $configThrottle['nextcloud']['stable']['release'] = (new \DateTime())->sub(new \DateInterval('PT6H'))->format('Y-m-d H:m'); + $configEnterprisePatchFallback = $config; + $configEnterprisePatchFallback['nextcloud']['enterprise']['win32'] = [ + 'version' => '4.0.10', + 'versionstring' => 'Nextcloud Client 4.0.10', + 'downloadurl' => 'https://download.nextcloud.com/desktop/stable/Nextcloud-4.0.10-setup.exe', + ]; + $configEnterprisePatchFallback['nextcloud']['stable']['win32'] = [ + 'version' => '33.0.5', + 'versionstring' => 'Nextcloud Client 33.0.5', + 'downloadurl' => 'https://download.nextcloud.com/desktop/stable/Nextcloud-33.0.5-setup.exe', + ]; + return [ // #0 Update segment is already allowed [ @@ -990,7 +1002,55 @@ public function updateDataProvider(): array ' - ], + ], + // #43 Manually upgraded enterprise client gets stable patches from its current major version + [ + 'nextcloud', + 'win32', + '33.0.2', + '', + '11', + '10.0.26080', + 'enterprise', + false, + false, + $configEnterprisePatchFallback, + ' +33.0.5Nextcloud Client 33.0.5https://download.nextcloud.com/desktop/stable/Nextcloud-33.0.5-setup.exe +' + ], + // #44 Enterprise fallback does not move a manually upgraded client to another major version + [ + 'nextcloud', + 'win32', + '32.0.2', + '', + '11', + '10.0.26080', + 'enterprise', + false, + false, + $configEnterprisePatchFallback, + ' + +' + ], + // #45 Enterprise fallback does not offer an update when the stable patch is already installed + [ + 'nextcloud', + 'win32', + '33.0.5', + '', + '11', + '10.0.26080', + 'enterprise', + false, + false, + $configEnterprisePatchFallback, + ' + +' + ], ]; } From 2942df7b7086cd8797f71de70b5be8393299e4d1 Mon Sep 17 00:00:00 2001 From: Rello Date: Mon, 1 Jun 2026 15:21:22 +0200 Subject: [PATCH 2/2] fix: macOS sparkle dependency Signed-off-by: Rello --- src/Response.php | 6 ++--- tests/unit/ResponseTest.php | 52 ++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/Response.php b/src/Response.php index 574d029..20ef8d4 100644 --- a/src/Response.php +++ b/src/Response.php @@ -112,14 +112,14 @@ private function getUpdateVersion() : array { } if ($this->channel === 'enterprise' && isset($enterprise)) { - if (version_compare($this->version, $enterprise['version']) === -1 || $isMacOs) { - return $enterprise; - } if (version_compare($this->version, $enterprise['version']) === 1 && version_compare($this->version, $stable['version']) === -1 && $this->hasSameMajorVersion($this->version, $stable['version'])) { return $stable; } + if (version_compare($this->version, $enterprise['version']) === -1 || $isMacOs) { + return $enterprise; + } return []; // Otherwise do not fall back to stable when there is no enterprise update } diff --git a/tests/unit/ResponseTest.php b/tests/unit/ResponseTest.php index cf8f3b7..79788d1 100644 --- a/tests/unit/ResponseTest.php +++ b/tests/unit/ResponseTest.php @@ -151,6 +151,22 @@ public function updateDataProvider(): array 'versionstring' => 'Nextcloud Client 33.0.5', 'downloadurl' => 'https://download.nextcloud.com/desktop/stable/Nextcloud-33.0.5-setup.exe', ]; + $configEnterprisePatchFallback['nextcloud']['enterprise']['macos'] = array_merge( + $configEnterprisePatchFallback['nextcloud']['enterprise']['macos'], + [ + 'version' => '4.0.10', + 'versionstring' => 'Nextcloud Client 4.0.10', + ] + ); + $configEnterprisePatchFallback['nextcloud']['stable']['macos'] = array_merge( + $configEnterprisePatchFallback['nextcloud']['stable']['macos'], + [ + 'version' => '33.0.5', + 'versionstring' => 'Nextcloud Client 33.0.5', + 'downloadurl' => 'https://download.nextcloud.com/desktop/stable/Nextcloud-33.0.5.pkg', + 'sparkleDownloadUrl' => 'https://download.nextcloud.com/desktop/stable/Nextcloud-33.0.5.pkg.tbz', + ] + ); return [ // #0 Update segment is already allowed @@ -1035,7 +1051,41 @@ public function updateDataProvider(): array ' ], - // #45 Enterprise fallback does not offer an update when the stable patch is already installed + // #45 Manually upgraded macOS enterprise client gets stable patches via Sparkle + [ + 'nextcloud', + 'macos', + '33.0.2', + '', + '14.0', + '22.00.00', + 'enterprise', + true, + false, + $configEnterprisePatchFallback, + ' + + + Download Channel + Most recent changes with links to updates. + en + + Nextcloud Client 33.0.5 + Wed, 13 July 16 21:07:31 +0200 + + 11.0 + + 33.0.0 + 33.0.0.0 + 33.0.1 + 33.0.1.0 + + https://download.nextcloud.com/desktop/stable/Nextcloud-33.0.5.pkg + + +' + ], + // #46 Enterprise fallback does not offer an update when the stable patch is already installed [ 'nextcloud', 'win32',