12 class IPTest extends PHPUnit_Framework_TestCase {
26 [
false,
'Boolean false is not an IP' ],
27 [
true,
'Boolean true is not an IP' ],
28 [
'',
'Empty string is not an IP' ],
29 [
'abc',
'Garbage IP string' ],
30 [
':',
'Single ":" is not an IP' ],
31 [
'2001:0DB8::A:1::1',
'IPv6 with a double :: occurrence' ],
32 [
'2001:0DB8::A:1::',
'IPv6 with a double :: occurrence, last at end' ],
33 [
'::2001:0DB8::5:1',
'IPv6 with a double :: occurrence, firt at beginning' ],
34 [
'124.24.52',
'IPv4 not enough quads' ],
35 [
'24.324.52.13',
'IPv4 out of range' ],
36 [
'.24.52.13',
'IPv4 starts with period' ],
37 [
'fc:100:300',
'IPv6 with only 3 words' ],
45 $this->assertTrue(
IP::isIPAddress(
'::' ),
'RFC 4291 IPv6 Unspecified Address' );
46 $this->assertTrue(
IP::isIPAddress(
'::1' ),
'RFC 4291 IPv6 Loopback Address' );
48 $this->assertTrue(
IP::isIPAddress(
'fc:100:a:d:1:e:ac:0/24' ),
'IPv6 range' );
49 $this->assertTrue(
IP::isIPAddress(
'fc::100:a:d:1:e:ac/96' ),
'IPv6 range with "::"' );
51 $validIPs = [
'fc:100::',
'fc:100:a:d:1:e:ac::',
'fc::100',
'::fc:100:a:d:1:e:ac',
52 '::fc',
'fc::100:a:d:1:e:ac',
'fc:100:a:d:1:e:ac:0',
'124.24.52.13',
'1.24.52.13' ];
53 foreach ( $validIPs
as $ip ) {
54 $this->assertTrue(
IP::isIPAddress( $ip ),
"$ip is a valid IP address" );
62 $this->assertFalse(
IP::isIPv6(
':fc:100::' ),
'IPv6 starting with lone ":"' );
63 $this->assertFalse(
IP::isIPv6(
'fc:100:::' ),
'IPv6 ending with a ":::"' );
64 $this->assertFalse(
IP::isIPv6(
'fc:300' ),
'IPv6 with only 2 words' );
65 $this->assertFalse(
IP::isIPv6(
'fc:100:300' ),
'IPv6 with only 3 words' );
68 $this->assertTrue(
IP::isIPv6(
'fc:100:a::' ) );
69 $this->assertTrue(
IP::isIPv6(
'fc:100:a:d::' ) );
70 $this->assertTrue(
IP::isIPv6(
'fc:100:a:d:1::' ) );
71 $this->assertTrue(
IP::isIPv6(
'fc:100:a:d:1:e::' ) );
72 $this->assertTrue(
IP::isIPv6(
'fc:100:a:d:1:e:ac::' ) );
74 $this->assertFalse(
IP::isIPv6(
'fc:100:a:d:1:e:ac:0::' ),
'IPv6 with 8 words ending with "::"' );
77 'IPv6 with 9 words ending with "::"'
81 $this->assertFalse(
IP::isIPv6(
'::0:' ),
'IPv6 ending in a lone ":"' );
83 $this->assertTrue(
IP::isIPv6(
'::' ),
'IPv6 zero address' );
87 $this->assertTrue(
IP::isIPv6(
'::fc:100:a' ) );
88 $this->assertTrue(
IP::isIPv6(
'::fc:100:a:d' ) );
89 $this->assertTrue(
IP::isIPv6(
'::fc:100:a:d:1' ) );
90 $this->assertTrue(
IP::isIPv6(
'::fc:100:a:d:1:e' ) );
91 $this->assertTrue(
IP::isIPv6(
'::fc:100:a:d:1:e:ac' ) );
93 $this->assertFalse(
IP::isIPv6(
'::fc:100:a:d:1:e:ac:0' ),
'IPv6 with "::" and 8 words' );
94 $this->assertFalse(
IP::isIPv6(
'::fc:100:a:d:1:e:ac:0:1' ),
'IPv6 with 9 words' );
96 $this->assertFalse(
IP::isIPv6(
':fc::100' ),
'IPv6 starting with lone ":"' );
97 $this->assertFalse(
IP::isIPv6(
'fc::100:' ),
'IPv6 ending with lone ":"' );
98 $this->assertFalse(
IP::isIPv6(
'fc:::100' ),
'IPv6 with ":::" in the middle' );
100 $this->assertTrue(
IP::isIPv6(
'fc::100' ),
'IPv6 with "::" and 2 words' );
101 $this->assertTrue(
IP::isIPv6(
'fc::100:a' ),
'IPv6 with "::" and 3 words' );
102 $this->assertTrue(
IP::isIPv6(
'fc::100:a:d' ),
'IPv6 with "::" and 4 words' );
103 $this->assertTrue(
IP::isIPv6(
'fc::100:a:d:1' ),
'IPv6 with "::" and 5 words' );
104 $this->assertTrue(
IP::isIPv6(
'fc::100:a:d:1:e' ),
'IPv6 with "::" and 6 words' );
105 $this->assertTrue(
IP::isIPv6(
'fc::100:a:d:1:e:ac' ),
'IPv6 with "::" and 7 words' );
106 $this->assertTrue(
IP::isIPv6(
'2001::df' ),
'IPv6 with "::" and 2 words' );
107 $this->assertTrue(
IP::isIPv6(
'2001:5c0:1400:a::df' ),
'IPv6 with "::" and 5 words' );
108 $this->assertTrue(
IP::isIPv6(
'2001:5c0:1400:a::df:2' ),
'IPv6 with "::" and 6 words' );
110 $this->assertFalse(
IP::isIPv6(
'fc::100:a:d:1:e:ac:0' ),
'IPv6 with "::" and 8 words' );
111 $this->assertFalse(
IP::isIPv6(
'fc::100:a:d:1:e:ac:0:1' ),
'IPv6 with 9 words' );
113 $this->assertTrue(
IP::isIPv6(
'fc:100:a:d:1:e:ac:0' ) );
121 $this->assertFalse(
IP::isIPv4( $bogusIP ), $desc );
126 [
false,
'Boolean false is not an IP' ],
127 [
true,
'Boolean true is not an IP' ],
128 [
'',
'Empty string is not an IP' ],
129 [
'abc',
'Letters are not an IP' ],
130 [
':',
'A colon is not an IP' ],
131 [
'124.24.52',
'IPv4 not enough quads' ],
132 [
'24.324.52.13',
'IPv4 out of range' ],
133 [
'.24.52.13',
'IPv4 starts with period' ],
142 $this->assertTrue(
IP::isIPv4( $ip ), $desc );
150 [
'124.24.52.13',
'Valid IPv4 address' ],
151 [
'1.24.52.13',
'Another valid IPv4 address' ],
152 [
'74.24.52.13/20',
'An IPv4 range' ],
160 foreach ( range( 0, 255 )
as $i ) {
161 $a = sprintf(
"%03d", $i );
162 $b = sprintf(
"%02d", $i );
163 $c = sprintf(
"%01d", $i );
164 foreach ( array_unique( [ $a, $b, $c ] )
as $f ) {
166 $this->assertTrue(
IP::isValid( $ip ),
"$ip is a valid IPv4 address" );
169 foreach ( range( 0x0, 0xFFFF, 0xF )
as $i ) {
170 $a = sprintf(
"%04x", $i );
171 $b = sprintf(
"%03x", $i );
172 $c = sprintf(
"%02x", $i );
173 foreach ( array_unique( [ $a, $b, $c ] )
as $f ) {
174 $ip =
"$f:$f:$f:$f:$f:$f:$f:$f";
175 $this->assertTrue(
IP::isValid( $ip ),
"$ip is a valid IPv6 address" );
179 $this->assertFalse(
IP::isValid(
':fc:100::' ),
'IPv6 starting with lone ":"' );
180 $this->assertFalse(
IP::isValid(
'fc:100:::' ),
'IPv6 ending with a ":::"' );
181 $this->assertFalse(
IP::isValid(
'fc:300' ),
'IPv6 with only 2 words' );
182 $this->assertFalse(
IP::isValid(
'fc:100:300' ),
'IPv6 with only 3 words' );
185 $this->assertTrue(
IP::isValid(
'fc:100:a:d:1:e::' ) );
186 $this->assertTrue(
IP::isValid(
'fc:100:a:d:1:e:ac::' ) );
188 $this->assertTrue(
IP::isValid(
'fc::100' ),
'IPv6 with "::" and 2 words' );
189 $this->assertTrue(
IP::isValid(
'fc::100:a' ),
'IPv6 with "::" and 3 words' );
190 $this->assertTrue(
IP::isValid(
'2001::df' ),
'IPv6 with "::" and 2 words' );
191 $this->assertTrue(
IP::isValid(
'2001:5c0:1400:a::df' ),
'IPv6 with "::" and 5 words' );
192 $this->assertTrue(
IP::isValid(
'2001:5c0:1400:a::df:2' ),
'IPv6 with "::" and 6 words' );
193 $this->assertTrue(
IP::isValid(
'fc::100:a:d:1' ),
'IPv6 with "::" and 5 words' );
194 $this->assertTrue(
IP::isValid(
'fc::100:a:d:1:e:ac' ),
'IPv6 with "::" and 7 words' );
198 'IPv6 with 8 words ending with "::"'
202 'IPv6 with 9 words ending with "::"'
211 foreach ( range( 256, 999 )
as $i ) {
212 $a = sprintf(
"%03d", $i );
213 $b = sprintf(
"%02d", $i );
214 $c = sprintf(
"%01d", $i );
215 foreach ( array_unique( [ $a, $b, $c ] )
as $f ) {
217 $this->assertFalse(
IP::isValid( $ip ),
"$ip is not a valid IPv4 address" );
220 foreach ( range(
'g',
'z' )
as $i ) {
221 $a = sprintf(
"%04s", $i );
222 $b = sprintf(
"%03s", $i );
223 $c = sprintf(
"%02s", $i );
224 foreach ( array_unique( [ $a, $b, $c ] )
as $f ) {
225 $ip =
"$f:$f:$f:$f:$f:$f:$f:$f";
226 $this->assertFalse(
IP::isValid( $ip ),
"$ip is not a valid IPv6 address" );
236 'c:ff:12:1:ea:d:321:5/120',
238 foreach ( $ipCIDRs
as $i ) {
240 "$i is an invalid IP address because it is a block" );
244 'www.xn--var-xla.net',
251 foreach ( $invalid
as $i ) {
252 $this->assertFalse(
IP::isValid( $i ),
"$i is an invalid IP address" );
261 [
'116.17.184.5/32' ],
263 [
'16.17.184.1/24' ],
264 [
'30.242.52.14/1' ],
265 [
'10.232.52.13/8' ],
266 [
'30.242.52.14/0' ],
268 [
'::c:f:2001/128' ],
269 [
'::10:f:2001/70' ],
281 $this->assertTrue(
IP::isValidBlock( $block ),
"$block is a valid IP block" );
289 $this->assertFalse(
IP::isValidBlock( $invalid ),
"$invalid is not a valid IP block" );
294 [
'116.17.184.5/33' ],
295 [
'0.17.184.5/130' ],
296 [
'16.17.184.1/-1' ],
297 [
'10.232.52.13/*' ],
298 [
'7.232.52.13/ab' ],
300 [
'::e:f:2001/129' ],
301 [
'::c:f:2001/228' ],
302 [
'::10:f:2001/-1' ],
304 [
'::86:f:2001/ab' ],
315 $this->assertEquals( $expected,
$result );
323 [
'0.0.0.0',
'0.0.0.0' ],
324 [
'0.0.0.0',
'00.00.00.00' ],
325 [
'0.0.0.0',
'000.000.000.000' ],
326 [
'141.0.11.253',
'141.000.011.253' ],
327 [
'1.2.4.5',
'1.2.4.5' ],
328 [
'1.2.4.5',
'01.02.04.05' ],
329 [
'1.2.4.5',
'001.002.004.005' ],
330 [
'10.0.0.1',
'010.0.000.1' ],
331 [
'80.72.250.4',
'080.072.250.04' ],
332 [
'Foo.1000.00',
'Foo.1000.00' ],
333 [
'Bar.01',
'Bar.01' ],
334 [
'Bar.010',
'Bar.010' ],
347 $this->assertEquals( $expected,
$result );
355 [
'00000001',
'0.0.0.1' ],
356 [
'01020304',
'1.2.3.4' ],
357 [
'7F000001',
'127.0.0.1' ],
358 [
'80000000',
'128.0.0.0' ],
359 [
'DEADCAFE',
'222.173.202.254' ],
360 [
'FFFFFFFF',
'255.255.255.255' ],
361 [
'8D000BFD',
'141.000.11.253' ],
362 [
false,
'IN.VA.LI.D' ],
363 [
'v6-00000000000000000000000000000001',
'::1' ],
364 [
'v6-20010DB885A3000000008A2E03707334',
'2001:0db8:85a3:0000:0000:8a2e:0370:7334' ],
365 [
'v6-20010DB885A3000000008A2E03707334',
'2001:db8:85a3::8a2e:0370:7334' ],
366 [
false,
'IN:VA::LI:D' ],
377 $this->assertEquals( $expected,
$result );
385 [
false,
'fc00::3' ], # RFC 4193 (local)
386 [
false,
'fc00::ff' ], # RFC 4193 (local)
387 [
false,
'127.1.2.3' ], # loopback
388 [
false,
'::1' ], # loopback
389 [
false,
'fe80::1' ], #
link-local
390 [
false,
'169.254.1.1' ], #
link-local
391 [
false,
'10.0.0.1' ], # RFC 1918 (
private)
392 [
false,
'172.16.0.1' ], # RFC 1918 (
private)
393 [
false,
'192.168.0.1' ], # RFC 1918 (
private)
394 [
true,
'2001:5c0:1000:a::133' ], #
public
395 [
true,
'fc::3' ], #
public
396 [
true,
'00FC::' ] #
public
402 $ff = [
false,
false ];
409 $this->assertEquals( $expected, long2ip( $parse[0] ),
"network shifting $CIDR" );
425 [
'0.0.0.1',
'00000001' ],
426 [
'255.0.0.0',
'FF000000' ],
427 [
'255.255.255.255',
'FFFFFFFF' ],
428 [
'10.188.222.255',
'0ABCDEFF' ],
432 [
'0.0.0.255',
'FF' ],
433 [
'0.0.255.0',
'FF00' ],
450 [
'0:0:0:0:0:0:0:1',
'00000000000000000000000000000001' ],
451 [
'0:0:0:0:0:0:FF:3',
'00000000000000000000000000FF0003' ],
452 [
'0:0:0:0:0:0:FF00:6',
'000000000000000000000000FF000006' ],
453 [
'0:0:0:0:0:0:FCCF:FAFF',
'000000000000000000000000FCCFFAFF' ],
454 [
'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF',
'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' ],
456 [
'0:0:0:0:0:0:0:0',
'0' ],
457 [
'0:0:0:0:0:0:0:1',
'1' ],
458 [
'0:0:0:0:0:0:0:FF',
'FF' ],
459 [
'0:0:0:0:0:0:0:FFD0',
'FFD0' ],
460 [
'0:0:0:0:0:0:FA00:0',
'FA000000' ],
461 [
'0:0:0:0:0:0:FCCF:FAFF',
'FCCFFAFF' ],
481 # 0 mask always result in array(0,0)
482 $this->assertEquals( [ 0, 0 ],
IP::parseCIDR(
'192.0.0.2/0' ) );
483 $this->assertEquals( [ 0, 0 ],
IP::parseCIDR(
'0.0.0.0/0' ) );
484 $this->assertEquals( [ 0, 0 ],
IP::parseCIDR(
'255.255.255.255/0' ) );
488 # This part test network shifting
489 $this->
assertNet(
'192.0.0.0',
'192.0.0.2/24' );
490 $this->
assertNet(
'192.168.5.0',
'192.168.5.13/24' );
491 $this->
assertNet(
'10.0.0.160',
'10.0.0.161/28' );
492 $this->
assertNet(
'10.0.0.0',
'10.0.0.3/28' );
493 $this->
assertNet(
'10.0.0.0',
'10.0.0.3/30' );
494 $this->
assertNet(
'10.0.0.4',
'10.0.0.4/30' );
495 $this->
assertNet(
'172.17.32.0',
'172.17.35.48/21' );
496 $this->
assertNet(
'10.128.0.0',
'10.135.0.0/9' );
497 $this->
assertNet(
'134.0.0.0',
'134.0.5.1/8' );
505 'Canonicalization of a valid IP returns it unchanged' );
537 # Format: (expected boolean, address, range, optional message)
540 [
true,
'192.0.2.0',
'192.0.2.0/24',
'Network address' ],
541 [
true,
'192.0.2.77',
'192.0.2.0/24',
'Simple address' ],
542 [
true,
'192.0.2.255',
'192.0.2.0/24',
'Broadcast address' ],
544 [
false,
'0.0.0.0',
'192.0.2.0/24' ],
545 [
false,
'255.255.255',
'192.0.2.0/24' ],
548 [
false,
'::1',
'2001:DB8::/32' ],
549 [
false,
'::',
'2001:DB8::/32' ],
550 [
false,
'FE80::1',
'2001:DB8::/32' ],
552 [
true,
'2001:DB8::',
'2001:DB8::/32' ],
553 [
true,
'2001:0DB8::',
'2001:DB8::/32' ],
554 [
true,
'2001:DB8::1',
'2001:DB8::/32' ],
555 [
true,
'2001:0DB8::1',
'2001:DB8::/32' ],
556 [
true,
'2001:0DB8:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF',
559 [
false,
'2001:0DB8:F::',
'2001:DB8::/96' ],
576 [
false,
'[',
'Unclosed square bracket' ],
577 [
false,
'[::',
'Unclosed square bracket 2' ],
578 [ [
'::',
false ],
'::',
'Bare IPv6 0' ],
579 [ [
'::1',
false ],
'::1',
'Bare IPv6 1' ],
580 [ [
'::',
false ],
'[::]',
'Bracketed IPv6 0' ],
581 [ [
'::1',
false ],
'[::1]',
'Bracketed IPv6 1' ],
582 [ [
'::1', 80 ],
'[::1]:80',
'Bracketed IPv6 with port' ],
583 [
false,
'::x',
'Double colon but no IPv6' ],
584 [ [
'x', 80 ],
'x:80',
'Hostname and port' ],
585 [
false,
'x:x',
'Hostname and invalid port' ],
586 [ [
'x',
false ],
'x',
'Plain hostname' ]
595 list( $host, $port, $defaultPort ) = $input;
607 [
'[::1]', [
'::1', 2, 2 ],
'IPv6 default port' ],
608 [
'[::1]:2', [
'::1', 2, 3 ],
'IPv6 non-default port' ],
609 [
'x', [
'x', 2, 2 ],
'Normal default port' ],
610 [
'x:2', [
'x', 2, 3 ],
'Normal non-default port' ],
627 [
'35.56.31.252/16',
'35.56.0.0/16',
'IPv4 range' ],
628 [
'135.16.21.252/24',
'135.16.21.0/24',
'IPv4 range' ],
629 [
'5.36.71.252/32',
'5.36.71.252/32',
'IPv4 silly range' ],
630 [
'5.36.71.252',
'5.36.71.252',
'IPv4 non-range' ],
631 [
'0:1:2:3:4:c5:f6:7/96',
'0:1:2:3:4:C5:0:0/96',
'IPv6 range' ],
632 [
'0:1:2:3:4:5:6:7/120',
'0:1:2:3:4:5:6:0/120',
'IPv6 range' ],
633 [
'0:e1:2:3:4:5:e6:7/128',
'0:E1:2:3:4:5:E6:7/128',
'IPv6 silly range' ],
634 [
'0:c1:A2:3:4:5:c6:7',
'0:C1:A2:3:4:5:C6:7',
'IPv6 non range' ],
643 $this->assertEquals( $prettified,
IP::prettifyIP( $ip ),
"Prettify of $ip" );
651 [
'0:0:0:0:0:0:0:0',
'::' ],
652 [
'0:0:0::0:0:0',
'::' ],
653 [
'0:0:0:1:0:0:0:0',
'0:0:0:1::' ],
655 [
'0::0:0:0:33:fef:b',
'::33:fef:b' ],
656 [
'3f:535:0:0:0:0:e:fbb',
'3f:535::e:fbb' ],
657 [
'0:0:fef:0:0:0:e:fbb',
'0:0:fef::e:fbb' ],
658 [
'abbc:2004::0:0:0:0',
'abbc:2004::' ],
659 [
'cebc:2004:f:0:0:0:0:0',
'cebc:2004:f::' ],
660 [
'0:0:0:0:0:0:0:0/16',
'::/16' ],
661 [
'0:0:0::0:0:0/64',
'::/64' ],
662 [
'0:0::f/52',
'::f/52' ],
663 [
'::0:0:33:fef:b/52',
'::33:fef:b/52' ],
664 [
'3f:535:0:0:0:0:e:fbb/48',
'3f:535::e:fbb/48' ],
665 [
'0:0:fef:0:0:0:e:fbb/96',
'0:0:fef::e:fbb/96' ],
666 [
'abbc:2004:0:0::0:0/40',
'abbc:2004::/40' ],
667 [
'aebc:2004:f:0:0:0:0:0/80',
'aebc:2004:f::/80' ],
testisIPAddress()
IP::isIPAddress.
static hexToOctet($ip_hex)
Converts a hexadecimal number to an IPv6 address in octet notation.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
assertNet($expected, $CIDR)
provideInvalidIPv4Addresses()
testisNotIPv4($bogusIP, $desc)
IP::isIPv4 provideInvalidIPv4Addresses.
static sanitizeIP($ip)
Convert an IP into a verbose, uppercase, normalized form.
static isInRange($addr, $range)
Determine if a given IPv4/IPv6 address is in a given CIDR network.
static sanitizeRange($range)
Gets rid of unneeded numbers in quad-dotted/octet IP strings For example, 127.111.113.151/24 -> 127.111.113.0/24.
static provideIPCIDRs()
Provider for IP::testSanitizeRange()
processing should stop and the error should be shown to the user * false
provideInvalidIPs()
Provide a list of things that aren't IP addresses.
testInvalidIPs()
IP::isValid.
testValidBlocks($block)
IP::isValidBlock provideValidBlocks.
testIsPublic($expected, $input)
IP::isPublic provideIsPublic.
static isIPv6($ip)
Given a string, determine if it as valid IP in IPv6 only.
static provideSanitizeIP()
Provider for IP::testSanitizeIP()
static isIPAddress($ip)
Determine if a string is as valid IP address or network (CIDR prefix).
static isPublic($ip)
Determine if an IP address really is an IP address, and if it is public, i.e.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message.Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item.Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page.Return false to stop further processing of the tag $reader:XMLReader object &$pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision.Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag.Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload.Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports.&$fullInterwikiPrefix:Interwiki prefix, may contain colons.&$pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable.Can be used to lazy-load the import sources list.&$importSources:The value of $wgImportSources.Modify as necessary.See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page.$context:IContextSource object &$pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect.&$title:Title object for the current page &$request:WebRequest &$ignoreRedirect:boolean to skip redirect check &$target:Title/string of redirect target &$article:Article object 'InternalParseBeforeLinks':during Parser's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InternalParseBeforeSanitize':during Parser's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings.Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not.Return true without providing an interwiki to continue interwiki search.$prefix:interwiki prefix we are looking for.&$iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user's email has been invalidated successfully.$user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification.Callee may modify $url and $query, URL will be constructed as $url.$query &$url:URL to index.php &$query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) &$article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() &$ip:IP being check &$result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from &$allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn't match your organization.$addr:The e-mail address entered by the user &$result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user &$result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we're looking for a messages file for &$file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED!Use $magicWords in a file listed in $wgExtensionMessagesFiles instead.Use this to define synonyms of magic words depending of the language &$magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces.Do not use this hook to add namespaces.Use CanonicalNamespaces for that.&$namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED!Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead.Use to define aliases of special pages names depending of the language &$specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names.&$names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page's language links.This is called in various places to allow extensions to define the effective language links for a page.$title:The page's Title.&$links:Associative array mapping language codes to prefixed links of the form"language:title".&$linkFlags:Associative array mapping prefixed links to arrays of flags.Currently unused, but planned to provide support for marking individual language links in the UI, e.g.for featured articles. 'LanguageSelector':Hook to change the language selector available on a page.$out:The output page.$cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED!Use HtmlPageLinkRendererBegin instead.Used when generating internal and interwiki links in Linker::link(), before processing starts.Return false to skip default processing and return $ret.See documentation for Linker::link() for details on the expected meanings of parameters.$skin:the Skin object $target:the Title that the link is pointing to &$html:the contents that the< a > tag should have(raw HTML) $result
testToHex($expected, $input)
IP::toHex provideToHex.
provideValidIPv4Address()
Provide some IPv4 addresses and ranges.
static provideIPsToPrettify()
Provider for IP::testPrettifyIP()
testPrettifyIP($ip, $prettified)
Test for IP::prettifyIP() provideIPsToPrettify.
static combineHostAndPort($host, $port, $defaultPort=false)
Given a host name and a port, combine them into host/port string like you might find in a URL...
static isValid($ip)
Validate an IP address.
testValidIPs()
IP::isValid.
static provideSplitHostAndPort()
Provider for IP::splitHostAndPort()
testCIDRParsing()
IP::parseCIDR() returns an array containing a signed IP address representing the network mask and the...
static isIPv4($ip)
Given a string, determine if it as valid IP in IPv4 only.
static provideIPsAndRanges()
Provider for testIPIsInRange()
static provideToHex()
Provider for IP::testToHex()
assertFalseCIDR($CIDR, $msg= '')
testIPIsInRange($expected, $addr, $range, $message= '')
Issues there are most probably from IP::toHex() or IP::parseRange() IP::isInRange provideIPsAndRanges...
testInvalidBlocks($invalid)
IP::isValidBlock provideInvalidBlocks.
provideIPsandHexes()
Provide some IP addresses and their equivalent hex representations.
static hexToQuad($ip_hex)
Converts a hexadecimal number to an IPv4 address in quad-dotted notation.
testSanitizeRange($input, $expected, $description)
Test for IP::sanitizeRange() provideIPCIDRs.
static toHex($ip)
Return a zero-padded upper case hexadecimal representation of an IP address.
testIPCanonicalizeOnValidIp()
IP::canonicalize.
testSanitizeIP($expected, $input)
IP::sanitizeIP provideSanitizeIP.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static canonicalize($addr)
Convert some unusual representations of IPv4 addresses to their canonical dotted quad representation...
static splitHostAndPort($both)
Given a host/port string, like one might find in the host part of a URL per RFC 2732, split the hostname part and the port part and return an array with an element for each.
testHexToOctet($octet, $hex)
IP::hexToOctet provideOctetsAndHexes.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
provideOctetsAndHexes()
Provide some hex and octet representations of the same IPs.
testSplitHostAndPort($expected, $input, $description)
Test for IP::splitHostAndPort().
provideValidBlocks()
Provide some valid IP blocks.
static provideIsPublic()
Provider for IP::testIsPublic()
static parseCIDR($range)
Convert a network specification in CIDR notation to an integer network and a number of bits...
testIsIPv4($ip, $desc)
IP::isIPv4 provideValidIPv4Address.
testIPCanonicalizeMappedAddress()
IP::canonicalize.
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template to be included in the link
static provideCombineHostAndPort()
Provider for IP::combineHostAndPort()
testCombineHostAndPort($expected, $input, $description)
Test for IP::combineHostAndPort() provideCombineHostAndPort.
isNotIPAddress($val, $desc)
IP::isIPAddress provideInvalidIPs.
testHexToQuad($ip, $hex)
IP::hexToQuad provideIPsAndHexes.
static isValidBlock($ipblock)
Validate an IP Block (valid address WITH a valid prefix).
static prettifyIP($ip)
Prettify an IP for display to end users.
Tests for IP validity functions.