Report any technical problems you discover and discuss solutions.

V3 beta: database response check incorrect - fixed

Plus d'informations
il y a 11 ans 1 semaine #2938 par jayaich
Hello,

I noticed in an error log that the users login date and username fields were being reported as failing to be updated in the database. For example, taken directly from the log file itself:

===================
16:32:50 - 29/07/2015 MINOR<Br>Failed to update users login time<Br>Failed to update users login time</p>*<p>16:32:50 - 29/07/2015 MINOR<Br>Failed to update users username
===================

I started a mariadb general log and could see the commands being executed ('update's basically). I then ran the update manually and got the response:

===================
MariaDB> UPDATE logindetails SET firstname = ...
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
===================

Looking in database_library.php shows that for delete and update commands it returns the number of rows (line 147): return $statement->rowCount(); /* number of rows affected */

However, in user_library.php it says (lines 228 and 241) :

=================
if(db_query($query, $params)){
=================

So if zero rows are affected, which is correct if the data hasn't changed, then this is treated as false/failed. The comparison should be against PHP 'false'. I changed both lines to say:

=================
if(db_query($query, $params) !== false){
=================

and the update failures have now stopped.


John.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 11 ans 1 semaine #2939 par JohnSmith
Réponse de JohnSmith sur le sujet V3 beta: database response check incorrect - fixed
Thanks John, I've updated those two lines (plus another) so it will make it into v3 when it is packaged tonight.

github.com/thexerteproject/xerteonlineto...a3b3d81b21a4e5023f8c
Les utilisateur(s) suivant ont remercié: jayaich

Connexion ou Créer un compte pour participer à la conversation.

Modérateurs: ronmjultenJohnSmith
Temps de génération de la page : 0.794 secondes
Copyright © 2026 The Xerte Project.
Xerte logo Apereo logo OSI Logo