From ec7567acc6283faf722fe703d1fcd85a2d6a5b5d Mon Sep 17 00:00:00 2001 From: Claus-Justus Heine Date: Fri, 5 Sep 2025 22:18:11 +0200 Subject: [PATCH 1/6] Bump max NC version to 32 --- appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 85de603..23c02e7 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -22,7 +22,7 @@ auth - + \OCA\UserSQL\Settings\Admin From 6d769253b882688e876e62500455aab73a45726d Mon Sep 17 00:00:00 2001 From: Claus-Justus Heine Date: Wed, 10 Sep 2025 22:01:42 +0200 Subject: [PATCH 2/6] Fix routes definitions. --- appinfo/routes.php | 96 +++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index dde5395..46429a6 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -2,8 +2,9 @@ /** * Nextcloud - user_sql * - * @copyright 2012-2015 Andreas Böhler + * @copyright 2025 Claus-Justus Heine * @copyright 2018 Marcin Łojewski + * @copyright 2012-2015 Andreas Böhler * @author Marcin Łojewski * * This program is free software: you can redistribute it and/or modify @@ -22,50 +23,49 @@ use OCA\UserSQL\AppInfo\Application; -$application = new Application(); -$application->registerRoutes( - $this, [ - "routes" => [ - [ - "name" => "settings#verifyDbConnection", - "url" => "/settings/db/verify", - "verb" => "POST" - ], - [ - "name" => "settings#saveProperties", - "url" => "/settings/properties", - "verb" => "POST" - ], - [ - "name" => "settings#clearCache", - "url" => "/settings/cache/clear", - "verb" => "POST" - ], - [ - "name" => "settings#tableAutocomplete", - "url" => "/settings/autocomplete/table", - "verb" => "POST" - ], - [ - "name" => "settings#userTableAutocomplete", - "url" => "/settings/autocomplete/table/user", - "verb" => "POST" - ], - [ - "name" => "settings#userGroupTableAutocomplete", - "url" => "/settings/autocomplete/table/user_group", - "verb" => "POST" - ], - [ - "name" => "settings#groupTableAutocomplete", - "url" => "/settings/autocomplete/table/group", - "verb" => "POST" - ], - [ - "name" => "settings#cryptoParams", - "url" => "/settings/crypto/params", - "verb" => "GET" - ], - ] - ] -); +$routes = [ + 'routes' => [ + [ + "name" => "settings#verifyDbConnection", + "url" => "/settings/db/verify", + "verb" => "POST" + ], + [ + "name" => "settings#saveProperties", + "url" => "/settings/properties", + "verb" => "POST" + ], + [ + "name" => "settings#clearCache", + "url" => "/settings/cache/clear", + "verb" => "POST" + ], + [ + "name" => "settings#tableAutocomplete", + "url" => "/settings/autocomplete/table", + "verb" => "POST" + ], + [ + "name" => "settings#userTableAutocomplete", + "url" => "/settings/autocomplete/table/user", + "verb" => "POST" + ], + [ + "name" => "settings#userGroupTableAutocomplete", + "url" => "/settings/autocomplete/table/user_group", + "verb" => "POST" + ], + [ + "name" => "settings#groupTableAutocomplete", + "url" => "/settings/autocomplete/table/group", + "verb" => "POST" + ], + [ + "name" => "settings#cryptoParams", + "url" => "/settings/crypto/params", + "verb" => "GET" + ], + ], +]; + +return $routes; From 36ad9389429301f7bf4d2d496d7539b4cf7a817c Mon Sep 17 00:00:00 2001 From: Claus-Justus Heine Date: Fri, 17 Oct 2025 16:53:08 +0200 Subject: [PATCH 3/6] UserBackend, fix action recursion guard --- lib/Backend/UserBackend.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Backend/UserBackend.php b/lib/Backend/UserBackend.php index 370d45d..842c1bc 100644 --- a/lib/Backend/UserBackend.php +++ b/lib/Backend/UserBackend.php @@ -261,13 +261,13 @@ final class UserBackend extends ABackend implements if ($user instanceof User) { $this->cache->set($cacheKey, $user); - // avoid recursion as the action may very well call into the UserManager again ... - $actions = $this->actions; - $this->actions = []; - foreach ($this->actions as $action) { + // avoid recursion as the action may very well call into the UserManager again ... + $actions = $this->actions; + $this->actions = []; + foreach ($actions as $action) { $action->doAction($user); } - $this->actions = $actions; + $this->actions = $actions; } return $user; From fad85d01e032bc93c3fa1314b030949a402cc3ad Mon Sep 17 00:00:00 2001 From: Claus-Justus Heine Date: Fri, 5 Dec 2025 10:45:00 +0100 Subject: [PATCH 4/6] DataQuery::connectToDatabase(), throw wenn called with empty configuration rather than producing obscure PHP errors. --- lib/Query/DataQuery.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Query/DataQuery.php b/lib/Query/DataQuery.php index ea33803..4203182 100644 --- a/lib/Query/DataQuery.php +++ b/lib/Query/DataQuery.php @@ -4,6 +4,8 @@ * * @copyright 2021 Marcin Łojewski * @author Marcin Łojewski + * @copyright 2025 Claus-Justus Heine + * @author Claus-Justus Heine * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -21,6 +23,8 @@ namespace OCA\UserSQL\Query; +use UnexpectedValueException; + use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Exception as DBALException; use OC\DB\Connection; @@ -151,6 +155,10 @@ class DataQuery "driverOptions" => array() ); + if (empty($this->properties[DB::DRIVER])) { + throw new UnexpectedValueException('Attempt to connect without configuration.'); + } + if ($this->properties[DB::DRIVER] == 'mysql') { if ($this->properties[DB::SSL_CA]) { $parameters["driverOptions"][\PDO::MYSQL_ATTR_SSL_CA] = \OC::$SERVERROOT . '/' . $this->properties[DB::SSL_CA]; From 601f7720cfbe4656ca984aa933bdeb0fa5a8a50e Mon Sep 17 00:00:00 2001 From: Claus-Justus Heine Date: Fri, 5 Dec 2025 11:01:12 +0100 Subject: [PATCH 5/6] fix(unconfigured): do not enable the backends without a complete configuration. Signed-off-by: Claus-Justus Heine --- lib/AppInfo/Application.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index c16d2e8..bd59629 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -2,10 +2,10 @@ /** * Nextcloud - user_sql * - * @copyright 2018 Marcin Łojewski - * @author Marcin Łojewski * @copyright 2025 Claus-Justus Heine * @author Claus-Justus Heine + * @copyright 2018 Marcin Łojewski + * @author Marcin Łojewski * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -63,6 +63,9 @@ class Application extends App implements IBootstrap IGroupManager $groupManager, Backend\GroupBackend $groupBackend, ) { + if (!$userBackend->isConfigured() || !$groupBackend->isConfigured()) { + return; + } $userManager->registerBackend($userBackend); $groupManager->addBackend($groupBackend); }); From db5bfeb85195b4991133aa27a59b7503a8436571 Mon Sep 17 00:00:00 2001 From: Claus-Justus Heine Date: Fri, 5 Dec 2025 11:22:33 +0100 Subject: [PATCH 6/6] Enable group and user backends separately, based on their individual configurations. This restores the behaviour of the app before I moved it to the IBoostrap stuff. Signed-off-by: Claus-Justus Heine --- lib/AppInfo/Application.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index bd59629..578a24a 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -63,11 +63,12 @@ class Application extends App implements IBootstrap IGroupManager $groupManager, Backend\GroupBackend $groupBackend, ) { - if (!$userBackend->isConfigured() || !$groupBackend->isConfigured()) { - return; + if ($userBackend->isConfigured()) { + $userManager->registerBackend($userBackend); + } + if ($groupBackend->isConfigured()) { + $groupManager->addBackend($groupBackend); } - $userManager->registerBackend($userBackend); - $groupManager->addBackend($groupBackend); }); } }