From 4c8daea9767a51931223269abe3b8e653dd21663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 20 Nov 2025 17:30:32 +0100 Subject: [PATCH 1/2] fix(files_external): Fix registration of listeners with PHP >= 8.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the lazy ghosts the constructor is not always called in files_external boot. This is a quick and dirty fix but we should instead move the code out of the constructors and to the boot method. Signed-off-by: Côme Chilliet --- apps/files_external/lib/AppInfo/Application.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php index a6c2aff947b67..6ddb2bb3140e0 100644 --- a/apps/files_external/lib/AppInfo/Application.php +++ b/apps/files_external/lib/AppInfo/Application.php @@ -89,7 +89,11 @@ public function boot(IBootContext $context): void { // force-load auth mechanisms since some will register hooks // TODO: obsolete these and use the TokenProvider to get the user's password from the session - $this->getAuthMechanisms(); + $objects = $this->getAuthMechanisms(); + foreach ($objects as $object) { + /* Use the object to trigger DI on PHP >= 8.4 */ + get_object_vars($object); + } } /** From dcb78191bf8861824a9d7e722c113241a31b683f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 20 Nov 2025 17:41:29 +0100 Subject: [PATCH 2/2] fix(files_external): Properly register event listeners in register method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the clean solution, LoginCredentials was the only auth class actually registering stuff in constructor. Signed-off-by: Côme Chilliet --- apps/files_external/lib/AppInfo/Application.php | 13 +++++-------- .../lib/Lib/Auth/Password/LoginCredentials.php | 8 -------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php index 6ddb2bb3140e0..1ad1a2ed779c7 100644 --- a/apps/files_external/lib/AppInfo/Application.php +++ b/apps/files_external/lib/AppInfo/Application.php @@ -42,6 +42,7 @@ use OCA\Files_External\Lib\Config\IBackendProvider; use OCA\Files_External\Listener\GroupDeletedListener; use OCA\Files_External\Listener\LoadAdditionalListener; +use OCA\Files_External\Listener\StorePasswordListener; use OCA\Files_External\Listener\UserDeletedListener; use OCA\Files_External\Service\BackendService; use OCP\AppFramework\App; @@ -51,7 +52,9 @@ use OCP\AppFramework\QueryException; use OCP\Files\Config\IMountProviderCollection; use OCP\Group\Events\GroupDeletedEvent; +use OCP\User\Events\PasswordUpdatedEvent; use OCP\User\Events\UserDeletedEvent; +use OCP\User\Events\UserLoggedInEvent; /** * @package OCA\Files_External\AppInfo @@ -72,6 +75,8 @@ public function register(IRegistrationContext $context): void { $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); $context->registerEventListener(GroupDeletedEvent::class, GroupDeletedListener::class); $context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); + $context->registerEventListener(UserLoggedInEvent::class, StorePasswordListener::class); + $context->registerEventListener(PasswordUpdatedEvent::class, StorePasswordListener::class); $context->registerConfigLexicon(ConfigLexicon::class); } @@ -86,14 +91,6 @@ public function boot(IBootContext $context): void { return $userConfigHandler; }); }); - - // force-load auth mechanisms since some will register hooks - // TODO: obsolete these and use the TokenProvider to get the user's password from the session - $objects = $this->getAuthMechanisms(); - foreach ($objects as $object) { - /* Use the object to trigger DI on PHP >= 8.4 */ - get_object_vars($object); - } } /** diff --git a/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php b/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php index ce38140b6eede..ec8498956983c 100644 --- a/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php +++ b/apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php @@ -11,18 +11,14 @@ use OCA\Files_External\Lib\DefinitionParameter; use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException; use OCA\Files_External\Lib\StorageConfig; -use OCA\Files_External\Listener\StorePasswordListener; use OCP\Authentication\Exceptions\CredentialsUnavailableException; use OCP\Authentication\LoginCredentials\IStore as CredentialsStore; -use OCP\EventDispatcher\IEventDispatcher; use OCP\IL10N; use OCP\ISession; use OCP\IUser; use OCP\IUserBackend; use OCP\LDAP\ILDAPProviderFactory; use OCP\Security\ICredentialsManager; -use OCP\User\Events\PasswordUpdatedEvent; -use OCP\User\Events\UserLoggedInEvent; /** * Username and password from login credentials, saved in DB @@ -35,7 +31,6 @@ public function __construct( protected ISession $session, protected ICredentialsManager $credentialsManager, private CredentialsStore $credentialsStore, - IEventDispatcher $eventDispatcher, private ILDAPProviderFactory $ldapFactory, ) { $this @@ -48,9 +43,6 @@ public function __construct( ->setFlag(DefinitionParameter::FLAG_HIDDEN) ->setFlag(DefinitionParameter::FLAG_OPTIONAL), ]); - - $eventDispatcher->addServiceListener(UserLoggedInEvent::class, StorePasswordListener::class); - $eventDispatcher->addServiceListener(PasswordUpdatedEvent::class, StorePasswordListener::class); } private function getCredentials(IUser $user): array {