Bug tracker

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

Memberlist sorting for last activity done on wrong array (fix completed in vcs)

memberlist.php includes a function to update the sorting of the last activity. But while the sorting works quite fine, it is done on the wrong array:
Code: Select all
         // If we sort by last active date we need to adjust the id cache due to user_lastvisit not being the last active date...
         if ($sort_key == 'l')
         {
            $lesser_than = ($sort_dir == 'a') ? -1 : 1;
            uasort($id_cache, create_function('$first, $second', "return (\$first['last_visit'] == \$second['last_visit']) ? 0 : ((\$first['last_visit'] < \$second['last_visit']) ? $lesser_than : ($lesser_than * -1));"));
         }

Since the sequence of the entries is determined by $user_list instead of $id_cache, sorting is done without effect to the search results.

To fix, line 1373 should be changed:
Code: Select all
            uasort($id_cache, create_function('$first, $second', "return (\$first['last_visit'] == \$second['last_visit']) ? 0 : ((\$first['last_visit'] < \$second['last_visit']) ? $lesser_than : ($lesser_than * -1));"));
to
Code: Select all
            usort($user_list, create_function('$first, $second', "global \$id_cache; return (\$id_cache[\$first]['last_visit'] == \$id_cache[\$second]['last_visit']) ? 0 : ((\$id_cache[\$first]['last_visit'] < \$id_cache[\$second]['last_visit']) ? $lesser_than : ($lesser_than * -1));"));
Pleas keep in mind, that this sorting will only affect the current page since the page filter is applied at an earlier time.

Comments / History

Changed ticket status from "New" to "Duplicate"

Action performed by Kellanved (Former Team Member) on Jan 6th 2008, 00:07

Posted by Kellanved (Former Team Member) on Jan 6th 2008, 00:09

Thanks for the patch, but this has been reported a few times already, so I'll mark it as dupe.

Posted by PhilippK (Translator) on Jan 13th 2008, 15:36

Kellanved, could you give a link to the duplicate or mention whether there is a plan either to fix this or to remove the faulty code?
Thanks.

Posted by Kellanved (Former Team Member) on Jan 13th 2008, 16:59

http://www.phpbb.com/bugs/phpbb3/ticket ... t_id=13141

I the one I can find right now, but there are several.

Assigned ticket to group "Development Team"

Action performed by Kellanved (Former Team Member) on Jan 13th 2008, 16:59

Changed ticket status from "Duplicate" to "Reviewed"

Action performed by Acyd Burn (Server Manager) on Feb 1st 2008, 12:43

Assigned ticket to user "Acyd Burn"

Action performed by Acyd Burn (Server Manager) on Feb 1st 2008, 12:43

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

Action performed by Acyd Burn (Server Manager) on Feb 1st 2008, 12:43

Linked ticket with changeset: r8359

Action performed by Anonymous (I am too lazy to register) on Feb 1st 2008, 12:45

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

Action performed by Acyd Burn (Server Manager) on Feb 1st 2008, 12:48

Ticket details

Related SVN changesets