Last modified: 2013-10-23 18:17:05 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T36475, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 34475 - Incorrect sorting columns in IP/CIDR format
Incorrect sorting columns in IP/CIDR format
Status: REOPENED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.18.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on: 27478
Blocks: 31601
  Show dependency treegraph
 
Reported: 2012-02-17 16:50 UTC by jebnor
Modified: 2013-10-23 18:17 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description jebnor 2012-02-17 16:50:27 UTC
Colums in the IP/CIDR format to not sort properly in class="wikitable sortable" tables.

IPs sort correctly, (apparently using numeric sort, which is nice.)
{| class="wikitable sortable"
! A !! IP 
|-
| errata-prod || 25.71.30.0 
|-
| errata-test || 25.71.31.0 
|-
| Satellite || 25.71.32.0 
|-
| foobar || 25.23.33.0
|-
| AD3 || 25.71.33.0
|-
| AD3 FOO || 25.71.34.0
|-
| zfs || 192.168.151.0
|}

Upon sorting by IP, we get a table like this (Text Rendered here)
+-------------+---------------
! A           ! IP         ^
+-------------+---------------
| foobar      | 25.23.33.0
| errata-prod | 25.71.30.0
| errata-test | 25.71.31.0
| Satellite   | 25.71.32.0
| AD3         | 25.71.33.0
| AD3 FOO     | 25.71.34.0
| zfs         | 192.168.151.0


However when we add the CIDR mask to the IPs, the table does not sort correctly.
{| class="wikitable sortable"
! A !! IP 
|-
| errata-prod || 25.71.30.0/24
|-
| errata-test || 25.71.31.0/24
|-
| Satellite || 25.71.32.0/24
|-
| foobar || 25.23.33.0/24
|-
| AD3 || 25.71.33.0/24
|-
| AD3 FOO || 25.71.34.0/24
|-
| zfs || 192.168.151.0/24
|}

Sorting by IP gives
+-------------+---------------
! A           ! IP          ^
+-------------+---------------
| errata-prod | 25.71.30.0/24
| errata-test | 25.71.31.0/24
| Satellite   | 25.71.32.0/24
| foobar      | 25.23.33.0/24
| AD3         | 25.71.33.0/24
| AD3 FOO     | 25.71.34.0/24
| zfs         | 192.168.151.0/24

Which is incorrect, 'foobar' is not where is should be. It appears to be sorted by the third decimal octet which is confirmed by changing the foobar value to '25.23.47.0/24'
Which gives the 'sorted' table
+-------------+-----------------
! A           ! IP            ^
+-------------+-----------------
| errata-prod | 25.71.30.0/24
| errata-test | 25.71.31.0/24
| Satellite   | 25.71.32.0/24
| AD3         | 25.71.33.0/24
| AD3 FOO     | 25.71.34.0/24
| foobar      | 25.23.47.0/24
| zfs         | 192.168.151.0/24

Changing the CIDR mask doesn't change the outcome

+-------------+-----------------
! A           ! IP            ^
+-------------+-----------------
| errata-prod | 25.71.30.0/16
| errata-test | 25.71.31.0/16
| Satellite   | 25.71.32.0/16
| AD3         | 25.71.33.0/16
| AD3 FOO     | 25.71.34.0/24
| foobar      | 25.23.47.0/16
| zfs         | 192.168.151.0/24


EXPECTED OUTCOME:
Table Sorted by IP/CIDR should output the rows in the same order as IP alone.
+-------------+-----------------
! A           ! IP            ^
+-------------+-----------------
| foobar      | 25.23.47.0/16
| errata-prod | 25.71.30.0/16
| errata-test | 25.71.31.0/16
| Satellite   | 25.71.32.0/16
| AD3         | 25.71.33.0/16
| AD3 FOO     | 25.71.34.0/24
| zfs         | 192.168.151.0/24
Comment 1 Derk-Jan Hartman 2012-02-18 13:18:06 UTC
The autodetection filter will detect this as IPAddresses and sort it like these, but IP/CIDR is not supported by the auto detection, causing unexpected behavior.

The proper solution here is to add CIDR support, or to enforce IP sorting by using "data-sort-type='IPAddress'" on the column. Problem is though that WMF wiki's still haven't enable HTML5 mode, making the latter option impossible.
Comment 2 Derk-Jan Hartman 2012-02-18 13:51:09 UTC
it matches one of the 3 'date' regexes in autodetect mode to be exact...
Comment 3 Derk-Jan Hartman 2012-02-18 14:35:40 UTC
Added support for CIDR notation in r111829
Comment 4 jebnor 2012-02-18 15:21:08 UTC
Thanks so much for the fix.  Minor issue with it.   The /xx value in the test cases are greater than the max  number of bits in the IP address, which is 32.  Also, the regexp looks for 1-3 digits in the /xx portion. Valid values would be 1-32.

These observations do not affect the correctness of the solution, but it may be prudent to minimize overlay with other formats.
Comment 5 Derk-Jan Hartman 2012-03-06 10:52:31 UTC
reverted
Comment 6 Derk-Jan Hartman 2012-03-06 10:58:03 UTC
I won't be reapplying this change btw, the requested complexity is too much. It has turned from 'accept CIDR notation" into "handle CIDR notation in sort algorithm". Turning it from a 1 hour patch into a multi hour exercise in math and efficiency, for which I do not have the time.
Comment 7 Antoine "hashar" Musso (WMF) 2012-03-06 11:00:01 UTC
Adding myself in CC as a reminder. Will probably finish the implementation post git migration.
Comment 8 Bartosz Dziewoński 2013-02-19 19:29:39 UTC
This will fix itself if bug 45161 is solved.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links