Fixed AdminCP user IP Address list is not sorted as expected

Xon

Well-known member
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.webp

This user does have some IPv6 addresses (off screen somewhere).
 
Last edited:
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:
Sorting by the MAX(log_date) should be acceptable/valid and makes the order more predictable at least.
 
Top Bottom