Supporting each other

Community forums

Welcome, Guest
Username: Password: Remember me
Report any technical problems you discover and discuss solutions.
  • Page:
  • 1

TOPIC:

V3 beta: database response check incorrect - fixed 9 years 3 months ago #2938

  • jayaich
  • jayaich's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 82
  • Thank you received: 5
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.

Please Log in or Create an account to join the conversation.

V3 beta: database response check incorrect - fixed 9 years 3 months ago #2939

  • JohnSmith
  • JohnSmith's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 397
  • Thank you received: 71
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
The following user(s) said Thank You: jayaich

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: ronmjultenJohnSmith
Time to create page: 0.047 seconds
Copyright © 2024 The Xerte Project.
Xerte logo Apereo logo OSI Logo

Search