Page MenuHomePhabricator

IPv4 addresses do not sort within sortable tables.
Closed, ResolvedPublic

Description

Author: david.potter

Description:
It would be nice if MediaWiki could correctly sort IPv4 addresses (e.g. 10.1.203.40) in sortable tables.

Currently, wikibits.js identifies them as numerics and refuses to sort them correctly. Prepending a "&" to force a text search doesn't help unless the IP addresses are uglified to include leading zeros (e.g. 010.001.203.040).

I've attached a patch that adds the ability to automatically identify and sort IPv4 addresses. It's my first MediaWiki contribution, so please review it carefully.


Version: 1.16.x
Severity: enhancement

Details

Reference
bz17141

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:26 PM
bzimport set Reference to bz17141.
bzimport added a subscriber: Unknown Object (MLST).

david.potter wrote:

Wikibits patch that adds the ability for sortable wikitables to sort IPv4 addresses

attachment wikibits-ipv4-address-patch.diff ignored as obsolete

david.potter wrote:

updated patch that handles whitespace to left or right of IP address

attachment wikibits-ipv4-address-patch.diff ignored as obsolete

bensimmons1 wrote:

(In reply to comment #2)

Created an attachment (id=5725) [details]
updated patch that handles whitespace to left or right of IP address

A fix for this problem would be very helpful - we use lots of IP addresses in sortable tables with MW and they have the exact problems described here. Unfortunately I am not a programmer so I can't review the code.

david.potter wrote:

FWIW, this patch has been in operations at our facility for about a year now with no problems.

Does the patch still apply cleanly? (For the lazy ones of us here ;))

david.potter wrote:

(In reply to comment #5)

Does the patch still apply cleanly? (For the lazy ones of us here ;))

Oh God no. Hasn't applied cleanly since 1.12. That'll teach me to upload patches here instead of just committing them to trunk.

Removing patch and needs-review

Gonna need manually remaking...

david.potter wrote:

updated for compatibility with development version

Attached:

david.potter wrote:

applies cleanly to 1.16-svn

Do not mark bugs fixed until the patch has been applied.

Very True

I'll see if i can apply and test it in a little bit for you :)

Why does ts_parseIP() have an "octetlist" var (and not "quadlist"). Also, it probably could use a for loop to reduce the duplication.

david.potter wrote:

(In reply to comment #12)

Why does ts_parseIP() have an "octetlist" var (and not "quadlist").

ts_parseIP() has an "octetlist" because it contains a list of octets.

Why are they "octets" and not "quads"? Because the specification for the Internet Protocol calls these items "octets". See RFC 791 (Postel, 1981).

Why does the RFC refer to them as "octets" instad of "bytes"? Because the term "octet" denotes to 8 bits, whereas "byte" refers to an undefined group of bits (usually 8 bits, but 6,7,or 10 on some computer architectures.) This is an important distinction for a networking protocol whose goal is to enable communications between systems regardless of processing architecture.

"octet" makes sense on the bit level, though this patch doesn't operate on that level. It's just exploding the dotted-quad notation and padding the integers. The use of "octet" just seemed a bit odd. Probably just personal preference :)

r86088 is seriously broken and may get reverted; reopening. Needs unit tests (see initial basic unit tests in r90595 which show up errors; will also need tests for the particular case this bug is about.)

Test cases and a fix for single-digit octets added in r90637. Needs merge to 1.18 branch, marked in CR.

Re-resolving fixed.