Skip to content

Commit 3f77f3a

Browse files
committed
fix(versionCheck): use version_compare and IConfig::getSystemValueString('version', '0.0.0') to check the server version
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent 60ea3bf commit 3f77f3a

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

lib/Controller/Id4meController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(
5858
IRequest $request,
5959
private ISecureRandom $random,
6060
private ISession $session,
61-
IConfig $config,
61+
private IConfig $config,
6262
private IL10N $l10n,
6363
private ITimeFactory $timeFactory,
6464
private IClientService $clientService,
@@ -322,7 +322,8 @@ public function code(string $state = '', string $code = '', string $scope = '')
322322
// Set last password confirm to the future as we don't have passwords to confirm against with SSO
323323
$this->session->set('last-password-confirm', $this->timeFactory->getTime() + 4 * 365 * 24 * 3600);
324324

325-
/** @psalm-suppress UndefinedVariable Replace with ServerVersion once we depends on NC 31 */
326-
return new RedirectResponse($OC_Version[0] >= 32 ? $this->urlGenerator->linkToDefaultPageUrl() : \OC_Util::getDefaultPageUrl());
325+
/** Replace with ServerVersion once we depends on NC 31 */
326+
$is32OrGreater = version_compare($this->config->getSystemValueString('version', '0.0.0'), '32.0.0', '>=');
327+
return new RedirectResponse($is32OrGreater ? $this->urlGenerator->linkToDefaultPageUrl() : \OC_Util::getDefaultPageUrl());
327328
}
328329
}

lib/Controller/LoginController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,9 @@ public function code(string $state = '', string $code = '', string $scope = '',
746746
return $this->getRedirectResponse($redirectUrl);
747747
}
748748

749-
/** @psalm-suppress UndefinedVariable Replace with ServerVersion once we depends on NC 31 */
750-
return new RedirectResponse($OC_Version[0] >= 32 ? $this->urlGenerator->linkToDefaultPageUrl() : \OC_Util::getDefaultPageUrl());
749+
/** Replace with ServerVersion once we depends on NC 31 */
750+
$is32OrGreater = version_compare($this->config->getSystemValueString('version', '0.0.0'), '32.0.0', '>=');
751+
return new RedirectResponse($is32OrGreater ? $this->urlGenerator->linkToDefaultPageUrl() : \OC_Util::getDefaultPageUrl());
751752
}
752753

753754
/**

lib/User/Backend.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ private function checkFirstLogin(string $userId): bool {
454454

455455
$firstLogin = $user->getLastLogin() === 0;
456456
if ($firstLogin) {
457-
/** @psalm-suppress UndefinedVariable Replace with ServerVersion once we depend on NC 31 */
458-
if ($OC_Version[0] >= 34) {
457+
/** Replace with ServerVersion once we depend on NC 31 */
458+
if (version_compare($this->config->getSystemValueString('version', '0.0.0'), '34.0.0', '>=')) {
459459
Server::get(ISetupManager::class)->setupForUser($user);
460460
} else {
461461
\OC_Util::setupFS($userId);

0 commit comments

Comments
 (0)