You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{"reqId":"wwrjPQE2Tzll6lg4zzJD","level":3,"time":"2024-04-24T19:20:38+00:00","remoteAddr":"94.219.34.169","user":"XXXX","app":"user_sql","method":"GET","url":"/settings/admin/logging","message":"Could not execute the query: SELECT COUNT(u.username) AS count FROM aase6_users u WHERE u.username LIKE :search ","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36","version":"29.0.0.19","exception":{"Exception":"Doctrine\DBAL\Exception\TableNotFoundException","Message":"An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'owncloud.aase6_users' doesn't exist","Code":1146,"Trace":
The table is aase6_user. Ther could be something wrong with the parameters or binding of parameter (in PDO/Statment.php passing $params to statement is depreceated.
I have the same problem, but I'm trying to access a view in a different mysql database (dbname=xxx_admidio) on the same server. I did a little debugging and it seems that even though the user_sql passes in the correct dbname in the $parameters to the $connectionFactory->getConnection call in lib/Query/DataQuery.php, the connection is created to the default nextcloud database...
If I add the following code after the getConnection call:
$result = $this->connection->fetchOne("SELECT DATABASE();");
$this->logger->warning("MySQL: Connected to DB ".$result);
The log output is: "MySQL: Connected to DB xxx_nextcloud"
rather than the correct database xxx_admidio
After some more debugging, I seem to understand how the problem appeared:
In the commit nextcloud/server@79c4986, the Nextcloud server code switched from using \Doctrine\DBAL\Connection for the DB connections to Doctrine\DBAL\Connections\PrimaryReadReplicaConnection.
Apparently PrimaryReadReplicaConnection uses a different array structure for its arguments (connection params are stored in the ['primary'] sub-array instead of first-level array elements). Unfortunately, the code in ConnectionFactory::getConnection (https://github.com/nextcloud/server/blob/147426c3ca7183ad065293bd9b600e10adde4abf/lib/private/DB/ConnectionFactory.php#L129) merges in the connection parameters as first-level arguments (as was required for the old Connection class) rather than into the ['primary'] sub-array, which is now needed for the PrimaryReadReplicaConnection.
I suppose the correct fix would be to properly fix the ConnectionFactory to override the primary connection data instead of merging the params at top-level, where they are never used. I'll try to submit a issue with the nextcloud server repo.
However, this (1) depends on the specific Nextcloud Server version, (2) brings in the logic from the underlying ConnectionFactory implementation to third-party apps (i.e. it's not transparent) for no good reason and (3) might break at any time the nextcloud server chooses to fix this issue.
Any news on this? While the patches shown above allow at least to login again. Groups are not working for me with NC29
All file shares are gone for the users as they are group based in my installation :(
Is user_sql officially supported by nextcloud and if yes, why don't they check if it breaks when touching the server code? :/
Reacted by tobybryans, Stefan Sander and Robert Barsch
It seems that "Nextcloud Hub 8 (29.0.7)" switched back to the old param structure, so the workaround from April 29 is no longer needed (and indeed breaks user_sql). I switched back to the original user_sql code and it seems to work for now.
Activity
kainhofer commentedon Apr 29, 2024
I have the same problem, but I'm trying to access a view in a different mysql database (dbname=xxx_admidio) on the same server. I did a little debugging and it seems that even though the user_sql passes in the correct dbname in the $parameters to the $connectionFactory->getConnection call in lib/Query/DataQuery.php, the connection is created to the default nextcloud database...
If I add the following code after the getConnection call:
The log output is:
"MySQL: Connected to DB xxx_nextcloud"rather than the correct database xxx_admidio
kainhofer commentedon Apr 29, 2024
After some more debugging, I seem to understand how the problem appeared:
In the commit nextcloud/server@79c4986, the Nextcloud server code switched from using
\Doctrine\DBAL\Connectionfor the DB connections toDoctrine\DBAL\Connections\PrimaryReadReplicaConnection.Apparently PrimaryReadReplicaConnection uses a different array structure for its arguments (connection params are stored in the ['primary'] sub-array instead of first-level array elements). Unfortunately, the code in ConnectionFactory::getConnection (https://github.com/nextcloud/server/blob/147426c3ca7183ad065293bd9b600e10adde4abf/lib/private/DB/ConnectionFactory.php#L129) merges in the connection parameters as first-level arguments (as was required for the old Connection class) rather than into the ['primary'] sub-array, which is now needed for the PrimaryReadReplicaConnection.
So, while the old code needed
the new Primary ReadReplicaConnection now needs them in the primary sub-array:
For a difference of the params, I found this nice page:
https://blog.adamcameron.me/2023/01/php-primaryreadreplicaconnection.html
Without that page, I would still be debugging...
I suppose the correct fix would be to properly fix the ConnectionFactory to override the primary connection data instead of merging the params at top-level, where they are never used. I'll try to submit a issue with the nextcloud server repo.
kainhofer commentedon Apr 29, 2024
As a quick fix (ONLY for NC29!!!), one can adjust the user_sql code with the following patch:
However, this (1) depends on the specific Nextcloud Server version, (2) brings in the logic from the underlying ConnectionFactory implementation to third-party apps (i.e. it's not transparent) for no good reason and (3) might break at any time the nextcloud server chooses to fix this issue.
enh: Implement PrimaryReadReplicaConnection
RealKoenisch commentedon Apr 29, 2024
Positiv: I tried your small patch - it works in NC-29.
DataQuery, need to set primary and replica servers for NC29.
FischFischer commentedon Jun 4, 2024
Where / at which file did you do your changes?
RealKoenisch commentedon Jun 4, 2024
The changes are in the fork from rotdrop. Not Master but cafevdb/stable 29
https://github.com/rotdrop/user_sql/tree/production/cafevdb/stable29
The Changes are made in "lib/Query/DataQuery.php"
The git is out of date - is there someone who can implement the changes to this version?
KR
d-jsb commentedon Jul 3, 2024
Any news on this? While the patches shown above allow at least to login again. Groups are not working for me with NC29
All file shares are gone for the users as they are group based in my installation :(
Is user_sql officially supported by nextcloud and if yes, why don't they check if it breaks when touching the server code? :/
StefanSander3 commentedon Sep 10, 2024
Hey @RealKoenisch,
what is the state with this issue (see last comment) and this app in general. For some time now we can not use our nextcloud instance.
kainhofer commentedon Oct 6, 2024
It seems that "Nextcloud Hub 8 (29.0.7)" switched back to the old param structure, so the workaround from April 29 is no longer needed (and indeed breaks user_sql). I switched back to the original user_sql code and it seems to work for now.
flow10 commentedon Dec 7, 2024
Seems to be fixed by 5654799. Can someone comfirm?