Report any technical problems you discover and discuss solutions.

V3 beta: database response check incorrect - fixed

  • jayaich
  • Onderwerp Auteur
  • Offline
  • Premium lid
  • Premium lid
Meer
11 jaren 4 dagen geleden #2938 door 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.

Graag Inloggen of een account aanmaken deelnemen aan het gesprek.

Meer
11 jaren 4 dagen geleden #2939 door JohnSmith
Beantwoord door JohnSmith in topic 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
De volgende gebruiker (s) zei dank u: jayaich

Graag Inloggen of een account aanmaken deelnemen aan het gesprek.

Moderators: ronmjultenJohnSmith
Tijd voor maken pagina: 0.134 seconden
Copyright © 2026 The Xerte Project.
Xerte logo Apereo logo OSI Logo