From 06a2ad221f039ec3ff5d5fabae46f1c62ae90ebe Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Thu, 12 Mar 2026 11:51:49 +0100 Subject: [PATCH 1/3] fix: Use newer API when available OC_Util is on the way out Signed-off-by: Carl Schwan --- lib/Controller/Id4meController.php | 4 +++- lib/Controller/LoginController.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Controller/Id4meController.php b/lib/Controller/Id4meController.php index 040c89895..2d3d0b624 100644 --- a/lib/Controller/Id4meController.php +++ b/lib/Controller/Id4meController.php @@ -44,6 +44,7 @@ use OCP\Security\ICrypto; use OCP\Security\ISecureRandom; +use OCP\ServerVersion; use OCP\Util; use Psr\Log\LoggerInterface; @@ -71,6 +72,7 @@ public function __construct( private ID4MeService $id4MeService, private LoggerInterface $logger, private ICrypto $crypto, + private ServerVersion $serverVersion, ) { parent::__construct($request, $config, $l10n); @@ -322,6 +324,6 @@ public function code(string $state = '', string $code = '', string $scope = '') // Set last password confirm to the future as we don't have passwords to confirm against with SSO $this->session->set('last-password-confirm', strtotime('+4 year', time())); - return new RedirectResponse(\OC_Util::getDefaultPageUrl()); + return new RedirectResponse($this->serverVersion->getMajorVersion() >= 32 ? $this->urlGenerator->linkToDefaultPageUrl() : \OC_Util::getDefaultPageUrl()); } } diff --git a/lib/Controller/LoginController.php b/lib/Controller/LoginController.php index 90b3d51e4..4a3d1f655 100644 --- a/lib/Controller/LoginController.php +++ b/lib/Controller/LoginController.php @@ -58,6 +58,7 @@ use OCP\IUserSession; use OCP\Security\ICrypto; use OCP\Security\ISecureRandom; +use OCP\ServerVersion; use OCP\Session\Exceptions\SessionNotAvailableException; use OCP\User\Events\BeforeUserLoggedInEvent; use OCP\User\Events\UserCreatedEvent; @@ -99,6 +100,7 @@ public function __construct( private ICrypto $crypto, private TokenService $tokenService, private OidcService $oidcService, + private ServerVersion $serverVersion, ) { parent::__construct($request, $config, $l10n); } @@ -696,7 +698,7 @@ public function code(string $state = '', string $code = '', string $scope = '', return $this->getRedirectResponse($redirectUrl); } - return new RedirectResponse(\OC_Util::getDefaultPageUrl()); + return new RedirectResponse($this->serverVersion->getMajorVersion() >= 32 ? $this->urlGenerator->linkToDefaultPageUrl() : \OC_Util::getDefaultPageUrl()); } /** From e92c120575101569b5d32be40c6ebf9c05e26012 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Thu, 12 Mar 2026 11:55:20 +0100 Subject: [PATCH 2/3] refactor(backend): Use non-deprecated methods when possible Signed-off-by: Carl Schwan --- lib/User/Backend.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/User/Backend.php b/lib/User/Backend.php index 31b0317ed..63f8aae57 100644 --- a/lib/User/Backend.php +++ b/lib/User/Backend.php @@ -26,6 +26,8 @@ use OCP\DB\Exception; use OCP\EventDispatcher\GenericEvent; use OCP\EventDispatcher\IEventDispatcher; +use OCP\Files\IRootFolder; +use OCP\Files\ISetupManager; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\IConfig; @@ -35,11 +37,13 @@ use OCP\IUser; use OCP\IUserManager; use OCP\Server; +use OCP\ServerVersion; use OCP\User\Backend\ABackend; use OCP\User\Backend\ICountUsersBackend; use OCP\User\Backend\ICustomLogout; use OCP\User\Backend\IGetDisplayNameBackend; use OCP\User\Backend\IPasswordConfirmationBackend; +use OCP\User\Events\UserFirstTimeLoggedInEvent; use Psr\Log\LoggerInterface; use Throwable; @@ -63,6 +67,7 @@ public function __construct( private ProvisioningService $provisioningService, private LdapService $ldapService, private IUserManager $userManager, + private ServerVersion $serverVersion, ) { } @@ -391,9 +396,9 @@ private function checkFirstLogin(string $userId): bool { $firstLogin = $user->getLastLogin() === 0; if ($firstLogin) { - \OC_Util::setupFS($userId); + $this->serverVersion->getMajorVersion() >= 34 ? Server::get(ISetupManager::class)->setupForUser($user) : \OC_Util::setupFS($userId); // trigger creation of user home and /files folder - $userFolder = \OC::$server->getUserFolder($userId); + $userFolder = Server::get(IRootFolder::class)->getUserFolder($userId); try { // copy skeleton \OC_Util::copySkeleton($userId, $userFolder); @@ -403,8 +408,7 @@ private function checkFirstLogin(string $userId): bool { // trigger any other initialization $this->eventDispatcher->dispatch(IUser::class . '::firstLogin', new GenericEvent($user)); - // TODO add this when user_oidc min NC version is >= 28 - // $this->eventDispatcher->dispatchTyped(new UserFirstTimeLoggedInEvent($user)); + $this->eventDispatcher->dispatchTyped(new UserFirstTimeLoggedInEvent($user)); } $user->updateLastLoginTimestamp(); return $firstLogin; From ba4d3dbf61a5b303569f0ef607abde86ae5bac0e Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Fri, 13 Mar 2026 15:50:29 +0100 Subject: [PATCH 3/3] fix(psalm): ignore undefined classes until our min supported NC version includes them, trust the unit/integration tests to spot issues with the new methods/classes Signed-off-by: Julien Veyssier --- psalm.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/psalm.xml b/psalm.xml index 41798efa8..f7ab96596 100644 --- a/psalm.xml +++ b/psalm.xml @@ -46,6 +46,9 @@ + + + @@ -59,6 +62,7 @@ +