Bug tracker

This ticket has been moved to our new tracker. Open Ticket PHPBB3-8600 now.

Log page count incorrect in certain cases (fix completed in vcs)

Due to some wrong queries there is a possiblity that the log pages are incorrect counted.

Query to generate all data in admin logs:
Code: Select all
SELECT l.*, u.username, u.username_clean, u.user_colour
FROM phpbb_log l, phpbb_users u
WHERE l.log_type = 0
AND u.user_id = l.user_id
ORDER BY l.log_time DESC
LIMIT 4050, 30


Query used for counting the number of items:
Code: Select all
mysql> SELECT COUNT(l.log_id) AS total_entries
    -> FROM phpbb_log l
    -> WHERE l.log_type = 0
    -> AND l.log_time >= 0
    -> ;
+---------------+
| total_entries |
+---------------+
|          4072 |
+---------------+
1 row in set (0.02 sec)


Problem: In the count query there is no user table relation.

Count with user table included:
Code: Select all
mysql> SELECT COUNT(l.log_id) AS total_entries
    -> FROM phpbb_log l , phpbb_users u
    -> WHERE l.log_type = 0
    -> AND l.log_time >= 0
    -> AND u.user_id = l.user_id
    -> ;
+---------------+
| total_entries |
+---------------+
|          3698 |
+---------------+
1 row in set (0.02 sec)

This is ~400 lower, what is causing the last few pages aren't working.

Comments / History

Posted by bantu (3.0 Release Manager) on Aug 20th 2009, 08:15

The second query does take deleted accounts into account, the first however doesn't.

And for reference: user_delete() does not update the LOG_TABLE.

I think this should be fixed in 3.0.6.

Changed ticket severity from "Uncategorised/normal" to "Severe"

Action performed by Acyd Burn (Server Manager) on Aug 20th 2009, 14:21

Changed ticket status from "New" to "Fix in progress"

Action performed by ToonArmy (Development Team Member) on Aug 20th 2009, 17:04

Assigned ticket to user "ToonArmy"

Action performed by ToonArmy (Development Team Member) on Aug 20th 2009, 17:04

Posted by Acyd Burn (Server Manager) on Aug 21st 2009, 11:54

Damn... now i see you already take care of it Chris, and i already finished the patch. :/

For reference:
Code: Select all
Index: includes/functions_admin.php
===================================================================
--- includes/functions_admin.php   (revision 10034)
+++ includes/functions_admin.php   (working copy)
@@ -2716,8 +2716,9 @@
    }
 
    $sql = 'SELECT COUNT(l.log_id) AS total_entries
-      FROM ' . LOG_TABLE . " l
+      FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u
       WHERE l.log_type = $log_type
+         AND l.user_id = u.user_id
          AND l.log_time >= $limit_days " .
          (!empty($log_operation) ? "AND l.log_operation = '" . $db->sql_escape($log_operation) . "'" : '') . "
          $sql_forum";
Index: includes/functions_user.php
===================================================================
--- includes/functions_user.php   (revision 10034)
+++ includes/functions_user.php   (working copy)
@@ -538,6 +538,17 @@
 
    $cache->destroy('sql', MODERATOR_CACHE_TABLE);
 
+   // Delete user log entries about this user
+   $sql = 'DELETE FROM ' . LOG_TABLE . '
+      WHERE reportee_id = ' . $user_id;
+   $db->sql_query($sql);
+
+   // Change user_id to anonymous for this users triggered events
+   $sql = 'UPDATE ' . LOG_TABLE . '
+      SET user_id = ' . ANONYMOUS . '
+      WHERE user_id = ' . $user_id;
+   $db->sql_query($sql);
+
    // Delete the user_id from the zebra table
    $sql = 'DELETE FROM ' . ZEBRA_TABLE . '
       WHERE user_id = ' . $user_id . '

Assigned ticket to user "Acyd Burn"

Action performed by Acyd Burn (Server Manager) on Aug 25th 2009, 09:01

Linked ticket with changeset: r10053

Action performed by Acyd Burn (Server Manager) on Aug 25th 2009, 09:07

Changed ticket status from "Fix in progress" to "Fix completed in SVN"

Action performed by Acyd Burn (Server Manager) on Aug 25th 2009, 09:07

Ticket details

Related SVN changesets