• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed AdminCP user IP Address list is not sorted as expected

Xon

Well-known member
#1
Ordering of IPs isn't matching the expected 'ORDER BY log_date DESC' inside XenForo_Model_Ip::getIpsByUserId

I've had this happening with MariaDB 5.x, 10.0.x, 10.1.x;

ip.png

This user does have some IPv6 addresses (off screen somewhere).
 
Last edited:

Xon

Well-known member
#2
The bug is with the MAX(log_date) vs the ORDER BY clause:
Code:
  SELECT MAX(log_date), ip
  FROM xf_ip
  WHERE user_id = ?
  GROUP BY ip
  ORDER BY log_date DESC
This sorts from newest to oldest, but only displays the oldest logged date.

This means if someone switches devices and back again, the most recent IP is stuck down on the list somewhere.
 
Last edited:

Mike

XenForo developer
Staff member
#3
Sorting by the MAX(log_date) should be acceptable/valid and makes the order more predictable at least.