nextcloud / user_sql

🔒 App for authenticating Nextcloud users using SQL
GNU Affero General Public License v3.0
66 stars 33 forks source link

Compatibility with Nextcloud 21: Call to undefined method Doctrine\DBAL\Statement::errorInfo() #156

Closed leuedaniel closed 3 years ago

leuedaniel commented 3 years ago

Fresh Nextcloud install Version 21.0.0

Log says: Exception: Call to undefined method Doctrine\DBAL\Statement::errorInfo() /var/www/nextcloud_hgv/lib/private/AppFramework/App.php - line 157:

OC\AppFramework\Http\Dispatcher->dispatch()

/var/www/nextcloud_hgv/lib/private/Route/Router.php - line 302:

OC\AppFramework\App::main()

/var/www/nextcloud_hgv/lib/base.php - line 993:

OC\Route\Router->match()

/var/www/nextcloud_hgv/index.php - line 37:

OC::handleRequest()

Verursacht durchError: Call to undefined method Doctrine\DBAL\Statement::errorInfo() /var/www/nextcloud_hgv/apps/user_sql/lib/Query/DataQuery.php - line 183:

OCA\UserSQL\Query\DataQuery->execQuery()

/var/www/nextcloud_hgv/apps/user_sql/lib/Repository/UserRepository.php - line 146:

OCA\UserSQL\Query\DataQuery->queryValue()

/var/www/nextcloud_hgv/apps/user_sql/lib/Backend/UserBackend.php - line 195:

OCA\UserSQL\Repository\UserRepository->countAll()

/var/www/nextcloud_hgv/lib/private/User/Manager.php - line 444:

OCA\UserSQL\Backend\UserBackend->countUsers()

/var/www/nextcloud_hgv/apps/settings/lib/Controller/UsersController.php - line 206:

OC\User\Manager->countUsers()

/var/www/nextcloud_hgv/lib/private/AppFramework/Http/Dispatcher.php - line 218:

OCA\Settings\Controller\UsersController->usersList()

/var/www/nextcloud_hgv/lib/private/AppFramework/Http/Dispatcher.php - line 127:

OC\AppFramework\Http\Dispatcher->executeController()

/var/www/nextcloud_hgv/lib/private/AppFramework/App.php - line 157:

OC\AppFramework\Http\Dispatcher->dispatch()

/var/www/nextcloud_hgv/lib/private/Route/Router.php - line 302:

OC\AppFramework\App::main()

/var/www/nextcloud_hgv/lib/base.php - line 993:

OC\Route\Router->match()

/var/www/nextcloud_hgv/index.php - line 37:

OC::handleRequest()

mbartosch commented 3 years ago

Got the same problem after update from version 20 to 21. Any idea how to work around the problem until a fix has been published would be appreciated.

jeltevdw commented 3 years ago

This app is not yet compatible with Nextcloud 21. Doctrine DBAL has been updated to version 3.0.0 in Nextcloud 21, which requires adaptations to this app. So we need to wait for someone to make the necessary changes.

kainhofer commented 3 years ago

With the following small patch, at least nextcloud runs again here at my system. I haven't checked if everything works or if other changes are required, but at least NC no longer crashes:

--- user_sql/lib/Query/DataQuery.php.orig       2021-03-09 22:57:50.415939774 +0100
+++ user_sql/lib/Query/DataQuery.php    2021-03-09 23:02:57.938458206 +0100
@@ -119,10 +119,11 @@
             ["app" => $this->appName]
         );

-        if ($result->execute() !== true) {
-            $error = $result->errorInfo();
-            $this->logger->error(
-                "Could not execute the query: " . implode(", ", $error),
+       try {
+           $result->execute();
+       } catch (DBALExeption $e) {
+           $this->logger->error(
+                       "Could not execute the query: " . implode(", ", $e->getMessage(),
                 ["app" => $this->appName]
             );
             return false;
mlojewski-me commented 3 years ago

I will apply this path today and test app, and if everythings goes right realease a new version. I think if one query gets to the database correctly, there will be no more problems with Doctrine update

cptchaoscc commented 3 years ago

That patch is not enough, I'm afraid. Nextcloud 21 implemented a whole new version of DBAL so a lot of the functions break. https://docs.nextcloud.com//server/latest/developer_manual/app_publishing_maintenance/upgrade-guide.html https://github.com/doctrine/dbal/blob/3.0.x/UPGRADE.md I gave it a shot at fixing the issues, but admittedly I'm an awful coder. Biggest culprits that I've found so far are usage of Doctrine\DBAL\DBALException which has been renamed Doctrine\DBAL\Exception, the usage of setFetchMode() which has been removed entirely from DBAL and the fetch() method is replaced with fetchNumeric(), fetchAssociative() and fetchOne(). The DBALException is easy enough to fix as it's a simple renaming, but I have no idea how to replace the setFetchMode() and fetch(). Like I said, I'm a crappy coder and know extremely little about php. But as I understand it, implementing the changes necessary would break backwards compability, so that's something to keep in mind. Anyway, I hope this points someone smarter than me in the right direction and we can get an updated version

jeltevdw commented 3 years ago

Indeed, in my opinion, the patch is not enough. I am looking at the code, to see wether I can make the necessary changes to make it compatible with Doctrine 3.0. I cannot promise any results since I am not an experienced developer in the Nextcloud ecosystem.

martinschniewind commented 3 years ago

Thanks a lot to all of you trying to examine the problem. I would appreciate a solution very much and am willing to make a small monetary contribution...

leuedaniel commented 3 years ago

I would donate too

mlojewski-me commented 3 years ago

I will look at it tody

mlojewski-me commented 3 years ago

Done in https://github.com/nextcloud/user_sql/commit/49d1c76a6103bebba209c09f7aae550822c4d55a You can now test develep branch if its fine i will make a new release

leuedaniel commented 3 years ago

It works, thank you very much, where can we donate?

mlojewski-me commented 3 years ago

That's great I will make a release tonight then. If you want you can donate here: https://paypal.me/mlojewskime I would appreciate it very much.

mlojewski-me commented 3 years ago

https://apps.nextcloud.com/apps/user_sql/releases?platform=21#21 App has been released. Thanks for Your donation. Hope to get more time to contribute to this project.