The order ionce clicked on "visitors" on the access logs part, is weird. first it sorts by username (0-9,a-z) which is good but once it gets to ip addresses, there is no logic and hence you cant find an ip address the easy way. try to lookup 11.12.13.14 in http://drupal.org/admin/logs/visitors?page=0&sort=asc&order=Visitor and you will see there is no logic there.
I thought ordening would be based on first octet, second octet, third and fourt (hence 1.2.3.4 would be before 2.255.255.255) but is not. I think there is some hash over the complete ip address and the ordening is done on that, because all other logic escapes me.
anyone cares to dig into this?
Comment | File | Size | Author |
---|---|---|---|
#15 | 28175-15-access-log-sort.patch | 556 bytes | dcam |
#8 | 624812.patch | 576 bytes | bleen |
#8 | Top visitors in the past 3 days | d8-1.png | 72.06 KB | bleen |
#8 | Top visitors in the past 3 days | d8-2.png | 72.19 KB | bleen |
Comments
Comment #1
mikeryanComment #2
Harry Slaughterthe query is getting both the username and the hostname (ip). all sorts are done on the username field only. as he prepares to display the results of the query, he swaps in the hostname if the username is empty. so the hostnames are never really sorted at all (and probably shouldn't be values in a sortable field :)
$rows[] = array($account->hits, ($account->uid ? theme('username', $account) : $account->hostname), format_interval(round($account->total / 1000)), $ban_link);
Comment #3
markus_petrux CreditAttribution: markus_petrux commentedThis looks more like a feature request, and affects HEAD.
One solution to this problem would require to store IPs using a different format, maybe with the same approach implemented by phpBB. It uses CHAR(8) in the database, and converts the IP address to an hexadecimal value, where each part needs 2 bytes.
They use this functions:
That way IPs can be sorted on a more logical manner and is more optimal than converting IPs to longs.
Comment #4
markus_petrux CreditAttribution: markus_petrux commentedForgot to mention side effects related to such a change...
1) Stuff related to {access_log} table (statistics module).
2) Stuff related to {access} table (ip bans, etc.).
3) Watchdog.
4) Probably some contrib modules too.
I don't believe this will be done any time soon... and I can't think of any other reasonable way to sort IPs logically.
Comment #5
LAsan CreditAttribution: LAsan commentedDid current versions taken this feature request in consideration?
Moving to current.
Comment #6
Dave ReidComment #7
aspilicious CreditAttribution: aspilicious commentedNeeds to be fixed first in D8.
Comment #8
bleen CreditAttribution: bleen commentedWOW!! A seven-year-old issue... lets see if we cant just kill this one.
The attached patch fixes this "enough" IMO by always sorting the ip (ASC), but since this particular column in this particular table actually contains data from two DB columns (name & ip) it does not obey the tablesort link in the header.
I think this is an acceptable solution in this case though. If we want we can open up a feature request for orderByHeader() to accept multiple fields, but that is out of scope for this issue me thinks.
Comment #9
timmillwoodLooks good to me, a very simple solution to the issue that has the possibility to get back-ported to D7 too.
Although, my preference would be to remove all of the access_log functionality from D8 and just keep the node_counter.
Comment #10
catchThere's no index on hostname, could we get a before/after EXPLAIN for the query with the default sort? 'needs profiling' isn't quite the right tag but in the interests of not creating a new tag, adding that.
Comment #11
kscheirerThe explains are identical in all cases. Adding an index on accesslog.hostname did not alter the way either of these queries was executed. If we're sorting based on a calculated value like hits, I think there's no way to avoid using a temporary table.
Marking this as RTBC based on #9.
Without patch:
Patched:
Comment #12
timmillwoodSorry guys, I would rather see accesslog removed #1446956: Remove the accesslog from statistics
Comment #13
catchWhich was just committed.
Comment #14
kscheirerI think Dries trumped this issue in D8 :) - http://drupal.org/node/1446956#comment-6952152.
But we can still fix this in D7.
Comment #15
dcam CreditAttribution: dcam commentedBackported #8 to D7.
Comment #17
mikeytown2 CreditAttribution: mikeytown2 commented#15: 28175-15-access-log-sort.patch queued for re-testing.
Test went fatal on "ShortcutSetsTestCase->testShortcutSetDeleteDefault()". Seems outside of the scope of the patch thus retesting it.
Comment #18
thedavidmeister CreditAttribution: thedavidmeister commentedI tested this on simplytest.me by running some requests through a proxy service and reviewing the order of IP addresses shown. Looks good in D7. Code is fine too, patch still applies.
Comment #20
thedavidmeister CreditAttribution: thedavidmeister commentedtest forum pager fail?
Comment #21
thedavidmeister CreditAttribution: thedavidmeister commented15: 28175-15-access-log-sort.patch queued for re-testing.
Comment #23
David_Rothstein CreditAttribution: David_Rothstein commented15: 28175-15-access-log-sort.patch queued for re-testing.
Comment #24
David_Rothstein CreditAttribution: David_Rothstein commentedComment #26
dcam CreditAttribution: dcam commented15: 28175-15-access-log-sort.patch queued for re-testing.
Comment #27
dcam CreditAttribution: dcam commentedRe-setting RTBC status after random test failure.
Comment #28
dcam CreditAttribution: dcam commentedComment #30
amitgoyal CreditAttribution: amitgoyal commented15: 28175-15-access-log-sort.patch queued for re-testing.
Comment #32
dcam CreditAttribution: dcam commentedRe-setting RTBC status after random test failure.
Comment #33
David_Rothstein CreditAttribution: David_Rothstein commentedCommitted to 7.x - thanks!