Index: branches/REL1_18/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php |
— | — | @@ -5,11 +5,13 @@ |
6 | 6 | |
7 | 7 | class wfExpandUrl extends MediaWikiTestCase { |
8 | 8 | /** @dataProvider provideExpandableUrls */ |
9 | | - public function testWfExpandUrl( $fullUrl, $shortUrl, $defaultProto, $server, $httpsMode, $message ) { |
10 | | - // Fake $wgServer |
11 | | - global $wgServer; |
| 9 | + public function testWfExpandUrl( $fullUrl, $shortUrl, $defaultProto, $server, $canServer, $httpsMode, $message ) { |
| 10 | + // Fake $wgServer and $wgCanonicalServer |
| 11 | + global $wgServer, $wgCanonicalServer; |
12 | 12 | $oldServer = $wgServer; |
| 13 | + $oldCanServer = $wgCanonicalServer; |
13 | 14 | $wgServer = $server; |
| 15 | + $wgCanonicalServer = $canServer; |
14 | 16 | |
15 | 17 | // Fake $_SERVER['HTTPS'] if needed |
16 | 18 | if ( $httpsMode ) { |
— | — | @@ -20,8 +22,9 @@ |
21 | 23 | |
22 | 24 | $this->assertEquals( $fullUrl, wfExpandUrl( $shortUrl, $defaultProto ), $message ); |
23 | 25 | |
24 | | - // Restore $wgServer |
| 26 | + // Restore $wgServer and $wgCanonicalServer |
25 | 27 | $wgServer = $oldServer; |
| 28 | + $wgCanonicalServer = $oldCanServer; |
26 | 29 | } |
27 | 30 | |
28 | 31 | /** |
— | — | @@ -30,32 +33,43 @@ |
31 | 34 | public function provideExpandableUrls() { |
32 | 35 | $modes = array( 'http', 'https' ); |
33 | 36 | $servers = array( 'http' => 'http://example.com', 'https' => 'https://example.com', 'protocol-relative' => '//example.com' ); |
34 | | - $defaultProtos = array( 'http' => PROTO_HTTP, 'https' => PROTO_HTTPS, 'protocol-relative' => PROTO_RELATIVE, 'current' => PROTO_CURRENT ); |
| 37 | + $defaultProtos = array( 'http' => PROTO_HTTP, 'https' => PROTO_HTTPS, 'protocol-relative' => PROTO_RELATIVE, 'current' => PROTO_CURRENT, 'canonical' => PROTO_CANONICAL ); |
35 | 38 | |
36 | 39 | $retval = array(); |
37 | 40 | foreach ( $modes as $mode ) { |
38 | 41 | $httpsMode = $mode == 'https'; |
39 | 42 | foreach ( $servers as $serverDesc => $server ) { |
40 | | - foreach ( $defaultProtos as $protoDesc => $defaultProto ) { |
41 | | - $retval[] = array( 'http://example.com', 'http://example.com', $defaultProto, $server, $httpsMode, "Testing fully qualified http URLs (no need to expand) (defaultProto: $protoDesc , wgServer: $server, current request protocol: $mode )" ); |
42 | | - $retval[] = array( 'https://example.com', 'https://example.com', $defaultProto, $server, $httpsMode, "Testing fully qualified https URLs (no need to expand) (defaultProto: $protoDesc , wgServer: $server, current request protocol: $mode )" ); |
43 | | - # Would be nice to support this, see fixme on wfExpandUrl() |
44 | | - $retval[] = array( "wiki/FooBar", 'wiki/FooBar', $defaultProto, $server, $httpsMode, "Test non-expandable relative URLs (defaultProto: $protoDesc , wgServer: $server, current request protocol: $mode )" ); |
45 | | - |
46 | | - // Determine expected protocol |
47 | | - $p = $protoDesc . ':'; // default case |
48 | | - if ( $protoDesc == 'protocol-relative' ) { |
49 | | - $p = ''; |
50 | | - } else if ( $protoDesc == 'current' ) { |
51 | | - $p = "$mode:"; |
52 | | - } else { |
53 | | - $p = $protoDesc . ':'; |
| 43 | + foreach ( $modes as $canServerMode ) { |
| 44 | + $canServer = "$canServerMode://example2.com"; |
| 45 | + foreach ( $defaultProtos as $protoDesc => $defaultProto ) { |
| 46 | + $retval[] = array( 'http://example.com', 'http://example.com', $defaultProto, $server, $canServer, $httpsMode, "Testing fully qualified http URLs (no need to expand) (defaultProto: $protoDesc , wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )" ); |
| 47 | + $retval[] = array( 'https://example.com', 'https://example.com', $defaultProto, $server, $canServer, $httpsMode, "Testing fully qualified https URLs (no need to expand) (defaultProto: $protoDesc , wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )" ); |
| 48 | + # Would be nice to support this, see fixme on wfExpandUrl() |
| 49 | + $retval[] = array( "wiki/FooBar", 'wiki/FooBar', $defaultProto, $server, $canServer, $httpsMode, "Test non-expandable relative URLs (defaultProto: $protoDesc , wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )" ); |
| 50 | + |
| 51 | + // Determine expected protocol |
| 52 | + $p = $protoDesc . ':'; // default case |
| 53 | + if ( $protoDesc == 'protocol-relative' ) { |
| 54 | + $p = ''; |
| 55 | + } else if ( $protoDesc == 'current' ) { |
| 56 | + $p = "$mode:"; |
| 57 | + } else if ( $protoDesc == 'canonical' ) { |
| 58 | + $p = "$canServerMode:"; |
| 59 | + } else { |
| 60 | + $p = $protoDesc . ':'; |
| 61 | + } |
| 62 | + // Determine expected server name |
| 63 | + if ( $protoDesc == 'canonical' ) { |
| 64 | + $srv = $canServer; |
| 65 | + } else if ( $serverDesc == 'protocol-relative' ) { |
| 66 | + $srv = $p . $server; |
| 67 | + } else { |
| 68 | + $srv = $server; |
| 69 | + } |
| 70 | + |
| 71 | + $retval[] = array( "$p//wikipedia.org", '//wikipedia.org', $defaultProto, $server, $canServer, $httpsMode, "Test protocol-relative URL (defaultProto: $protoDesc, wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )" ); |
| 72 | + $retval[] = array( "$srv/wiki/FooBar", '/wiki/FooBar', $defaultProto, $server, $canServer, $httpsMode, "Testing expanding URL beginning with / (defaultProto: $protoDesc , wgServer: $server, wgCanonicalServer: $canServer, current request protocol: $mode )" ); |
54 | 73 | } |
55 | | - // Determine expected server name |
56 | | - $srv = $serverDesc == 'protocol-relative' ? $p . $server : $server; |
57 | | - |
58 | | - $retval[] = array( "$p//wikipedia.org", '//wikipedia.org', $defaultProto, $server, $httpsMode, "Test protocol-relative URL (defaultProto: $protoDesc, wgServer: $server, current request protocol: $mode )" ); |
59 | | - $retval[] = array( "$srv/wiki/FooBar", '/wiki/FooBar', $defaultProto, $server, $httpsMode, "Testing expanding URL beginning with / (defaultProto: $protoDesc , wgServer: $server, current request protocol: $mode )" ); |
60 | 74 | } |
61 | 75 | } |
62 | 76 | } |
Property changes on: branches/REL1_18/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php |
___________________________________________________________________ |
Added: svn:mergeinfo |
63 | 77 | Merged /branches/sqlite/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php:r58211-58321 |
64 | 78 | Merged /trunk/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php:r92580,92634,92713,92762,92765,92791,92854,92884,92886-92887,92894,92898,92907,92932,92958,93141,93149,93151,93233-93234,93258,93266,93303,93516-93518,93520,93818-93822,93847,93858,93891,93935-93936,94058,94062,94068,94107,94155,94235,94277,94346,94372,94422,94425,94444,94448,94456,94498,94517,94601,94630,94728,94738,94825,94862,94995-94997,95023,95042,95072-95073,95155,95327,95332,95410,95422,95426,95442,95468,95601,95812 |
65 | 79 | Merged /trunk/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrlTest.php:r95006 |
66 | 80 | Merged /branches/new-installer/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php:r43664-66004 |
67 | 81 | Merged /branches/REL1_15/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php:r51646 |
68 | 82 | Merged /branches/REL1_17/phase3/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php:r81445,81448 |
Index: branches/REL1_18/phase3/includes/Defines.php |
— | — | @@ -248,4 +248,4 @@ |
249 | 249 | define( 'PROTO_HTTPS', 'https://' ); |
250 | 250 | define( 'PROTO_RELATIVE', '//' ); |
251 | 251 | define( 'PROTO_CURRENT', null ); |
252 | | - |
| 252 | +define( 'PROTO_CANONICAL', 1 ); |
Index: branches/REL1_18/phase3/includes/User.php |
— | — | @@ -3278,7 +3278,7 @@ |
3279 | 3279 | |
3280 | 3280 | /** |
3281 | 3281 | * Internal function to format the e-mail validation/invalidation URLs. |
3282 | | - * This uses $wgArticlePath directly as a quickie hack to use the |
| 3282 | + * This uses a quickie hack to use the |
3283 | 3283 | * hardcoded English names of the Special: pages, for ASCII safety. |
3284 | 3284 | * |
3285 | 3285 | * @note Since these URLs get dropped directly into emails, using the |
— | — | @@ -3291,14 +3291,9 @@ |
3292 | 3292 | * @return String Formatted URL |
3293 | 3293 | */ |
3294 | 3294 | protected function getTokenUrl( $page, $token ) { |
3295 | | - global $wgArticlePath; |
3296 | | - return wfExpandUrl( |
3297 | | - str_replace( |
3298 | | - '$1', |
3299 | | - "Special:$page/$token", |
3300 | | - $wgArticlePath ), |
3301 | | - PROTO_HTTP |
3302 | | - ); |
| 3295 | + // Hack to bypass localization of 'Special:' |
| 3296 | + $title = Title::makeTitle( NS_MAIN, "Special:$page/$token" ); |
| 3297 | + return $title->getCanonicalUrl(); |
3303 | 3298 | } |
3304 | 3299 | |
3305 | 3300 | /** |
Index: branches/REL1_18/phase3/includes/search/SearchEngine.php |
— | — | @@ -472,7 +472,7 @@ |
473 | 473 | * @return String |
474 | 474 | */ |
475 | 475 | public static function getOpenSearchTemplate() { |
476 | | - global $wgOpenSearchTemplate, $wgServer; |
| 476 | + global $wgOpenSearchTemplate, $wgCanonicalServer; |
477 | 477 | if ( $wgOpenSearchTemplate ) { |
478 | 478 | return $wgOpenSearchTemplate; |
479 | 479 | } else { |
— | — | @@ -480,7 +480,7 @@ |
481 | 481 | if ( !$ns ) { |
482 | 482 | $ns = "0"; |
483 | 483 | } |
484 | | - return $wgServer . wfScript( 'api' ) . '?action=opensearch&search={searchTerms}&namespace=' . $ns; |
| 484 | + return $wgCanonicalServer . wfScript( 'api' ) . '?action=opensearch&search={searchTerms}&namespace=' . $ns; |
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
Index: branches/REL1_18/phase3/includes/GlobalFunctions.php |
— | — | @@ -432,6 +432,7 @@ |
433 | 433 | * PROTO_HTTPS: Output a URL starting with https:// |
434 | 434 | * PROTO_RELATIVE: Output a URL starting with // (protocol-relative URL) |
435 | 435 | * PROTO_CURRENT: Output a URL starting with either http:// or https:// , depending on which protocol was used for the current incoming request |
| 436 | + * PROTO_CANONICAL: For URLs without a domain, like /w/index.php , use $wgCanonicalServer. For protocol-relative URLs, use the protocol of $wgCanonicalServer |
436 | 437 | * |
437 | 438 | * @todo this won't work with current-path-relative URLs |
438 | 439 | * like "subdir/foo.html", etc. |
— | — | @@ -441,21 +442,34 @@ |
442 | 443 | * @return string Fully-qualified URL |
443 | 444 | */ |
444 | 445 | function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) { |
445 | | - global $wgServer; |
| 446 | + global $wgServer, $wgCanonicalServer; |
| 447 | + $serverUrl = $defaultProto === PROTO_CANONICAL ? $wgCanonicalServer : $wgServer; |
| 448 | + |
446 | 449 | if ( $defaultProto === PROTO_CURRENT ) { |
447 | 450 | $defaultProto = WebRequest::detectProtocol() . '://'; |
448 | 451 | } |
449 | 452 | |
450 | | - // Analyze $wgServer to obtain its protocol |
451 | | - $bits = wfParseUrl( $wgServer ); |
| 453 | + // Analyze $serverUrl to obtain its protocol |
| 454 | + $bits = wfParseUrl( $serverUrl ); |
452 | 455 | $serverHasProto = $bits && $bits['scheme'] != ''; |
| 456 | + |
| 457 | + if ( $defaultProto === PROTO_CANONICAL ) { |
| 458 | + if ( $serverHasProto ) { |
| 459 | + $defaultProto = $bits['scheme'] . '://'; |
| 460 | + } else { |
| 461 | + // $wgCanonicalServer doesn't have a protocol. This really isn't supposed to happen |
| 462 | + // Fall back to HTTP in this ridiculous case |
| 463 | + $defaultProto = PROTO_HTTP; |
| 464 | + } |
| 465 | + } |
| 466 | + |
453 | 467 | $defaultProtoWithoutSlashes = substr( $defaultProto, 0, -2 ); |
454 | 468 | |
455 | 469 | if( substr( $url, 0, 2 ) == '//' ) { |
456 | 470 | return $defaultProtoWithoutSlashes . $url; |
457 | 471 | } elseif( substr( $url, 0, 1 ) == '/' ) { |
458 | | - // If $wgServer is protocol-relative, prepend $defaultProtoWithoutSlashes, otherwise leave it alone |
459 | | - return ( $serverHasProto ? '' : $defaultProtoWithoutSlashes ) . $wgServer . $url; |
| 472 | + // If $serverUrl is protocol-relative, prepend $defaultProtoWithoutSlashes, otherwise leave it alone |
| 473 | + return ( $serverHasProto ? '' : $defaultProtoWithoutSlashes ) . $serverUrl . $url; |
460 | 474 | } else { |
461 | 475 | return $url; |
462 | 476 | } |
Property changes on: branches/REL1_18/phase3/includes/GlobalFunctions.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
463 | 477 | Merged /trunk/phase3/includes/GlobalFunctions.php:r94737,94990,95000-95002,95006-95007,95010-95011,95894 |
Index: branches/REL1_18/phase3/includes/Feed.php |
— | — | @@ -239,12 +239,15 @@ |
240 | 240 | * but can also be called separately. |
241 | 241 | */ |
242 | 242 | public function httpHeaders() { |
243 | | - global $wgOut; |
| 243 | + global $wgOut, $wgVaryOnXFPForAPI; |
244 | 244 | |
245 | 245 | # We take over from $wgOut, excepting its cache header info |
246 | 246 | $wgOut->disable(); |
247 | 247 | $mimetype = $this->contentType(); |
248 | 248 | header( "Content-type: $mimetype; charset=UTF-8" ); |
| 249 | + if ( $wgVaryOnXFPForAPI ) { |
| 250 | + $wgOut->addVaryHeader( 'X-Forwarded-Proto' ); |
| 251 | + } |
249 | 252 | $wgOut->sendCacheControl(); |
250 | 253 | |
251 | 254 | } |
— | — | @@ -273,7 +276,7 @@ |
274 | 277 | $this->httpHeaders(); |
275 | 278 | echo '<?xml version="1.0"?>' . "\n"; |
276 | 279 | echo '<?xml-stylesheet type="text/css" href="' . |
277 | | - htmlspecialchars( wfExpandUrl( "$wgStylePath/common/feed.css?$wgStyleVersion" ) ) . |
| 280 | + htmlspecialchars( wfExpandUrl( "$wgStylePath/common/feed.css?$wgStyleVersion", PROTO_CURRENT ) ) . |
278 | 281 | '"?' . ">\n"; |
279 | 282 | } |
280 | 283 | } |
Index: branches/REL1_18/phase3/includes/UserMailer.php |
— | — | @@ -509,7 +509,7 @@ |
510 | 510 | $keys = array(); |
511 | 511 | |
512 | 512 | if ( $this->oldid ) { |
513 | | - $difflink = wfExpandUrl( $this->title->getFullUrl( 'diff=0&oldid=' . $this->oldid ), PROTO_HTTP ); |
| 513 | + $difflink = $this->title->getCanonicalUrl( 'diff=0&oldid=' . $this->oldid ); |
514 | 514 | $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastvisited', $difflink ); |
515 | 515 | $keys['$OLDID'] = $this->oldid; |
516 | 516 | $keys['$CHANGEDORCREATED'] = wfMsgForContent( 'changed' ); |
— | — | @@ -526,17 +526,17 @@ |
527 | 527 | * revision. |
528 | 528 | */ |
529 | 529 | $keys['$NEWPAGE'] = wfMsgForContent( 'enotif_lastdiff', |
530 | | - wfExpandUrl( $this->title->getFullURL( "oldid={$this->oldid}&diff=next" ), PROTO_HTTP ) ); |
| 530 | + $this->title->getCanonicalUrl( "oldid={$this->oldid}&diff=next" ) ); |
531 | 531 | } |
532 | 532 | |
533 | 533 | $body = strtr( $body, $keys ); |
534 | 534 | $pagetitle = $this->title->getPrefixedText(); |
535 | 535 | $keys['$PAGETITLE'] = $pagetitle; |
536 | | - $keys['$PAGETITLE_URL'] = wfExpandUrl( $this->title->getFullUrl(), PROTO_HTTP ); |
| 536 | + $keys['$PAGETITLE_URL'] = $this->title->getCanonicalUrl(); |
537 | 537 | |
538 | 538 | $keys['$PAGEMINOREDIT'] = $medit; |
539 | 539 | $keys['$PAGESUMMARY'] = $summary; |
540 | | - $keys['$UNWATCHURL'] = wfExpandUrl( $this->title->getFullUrl( 'action=unwatch' ), PROTO_HTTP ); |
| 540 | + $keys['$UNWATCHURL'] = $this->title->getCanonicalUrl( 'action=unwatch' ); |
541 | 541 | |
542 | 542 | $subject = strtr( $subject, $keys ); |
543 | 543 | |
— | — | @@ -571,10 +571,10 @@ |
572 | 572 | $subject = str_replace( '$PAGEEDITOR', $name, $subject ); |
573 | 573 | $keys['$PAGEEDITOR'] = $name; |
574 | 574 | $emailPage = SpecialPage::getSafeTitleFor( 'Emailuser', $name ); |
575 | | - $keys['$PAGEEDITOR_EMAIL'] = wfExpandUrl( $emailPage->getFullUrl(), PROTO_HTTP ); |
| 575 | + $keys['$PAGEEDITOR_EMAIL'] = $emailPage->getCanonicalUrl(); |
576 | 576 | } |
577 | 577 | $userPage = $editor->getUserPage(); |
578 | | - $keys['$PAGEEDITOR_WIKI'] = wfExpandUrl( $userPage->getFullUrl(), PROTO_HTTP ); |
| 578 | + $keys['$PAGEEDITOR_WIKI'] = $userPage->getCanonicalUrl(); |
579 | 579 | $body = strtr( $body, $keys ); |
580 | 580 | $body = wordwrap( $body, 72 ); |
581 | 581 | |
Index: branches/REL1_18/phase3/includes/filerepo/File.php |
— | — | @@ -215,8 +215,12 @@ |
216 | 216 | * @return String |
217 | 217 | */ |
218 | 218 | public function getFullUrl() { |
219 | | - return wfExpandUrl( $this->getUrl() ); |
| 219 | + return wfExpandUrl( $this->getUrl(), PROTO_RELATIVE ); |
220 | 220 | } |
| 221 | + |
| 222 | + public function getCanonicalUrl() { |
| 223 | + return wfExpandUrl( $this->getUrl(), PROTO_CANONICAL ); |
| 224 | + } |
221 | 225 | |
222 | 226 | /** |
223 | 227 | * @return string |
Property changes on: branches/REL1_18/phase3/includes/filerepo/File.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
224 | 228 | Merged /trunk/phase3/includes/filerepo/File.php:r94737,94990,95000-95002,95006-95007,95010-95011,95894 |
Index: branches/REL1_18/phase3/includes/Export.php |
— | — | @@ -411,7 +411,7 @@ |
412 | 412 | } |
413 | 413 | |
414 | 414 | function homelink() { |
415 | | - return Xml::element( 'base', array(), Title::newMainPage()->getFullUrl() ); |
| 415 | + return Xml::element( 'base', array(), Title::newMainPage()->getCanonicalUrl() ); |
416 | 416 | } |
417 | 417 | |
418 | 418 | function caseSetting() { |
— | — | @@ -644,7 +644,7 @@ |
645 | 645 | " " . Xml::elementClean( 'comment', null, $file->getDescription() ) . "\n" . |
646 | 646 | " " . Xml::element( 'filename', null, $file->getName() ) . "\n" . |
647 | 647 | $archiveName . |
648 | | - " " . Xml::element( 'src', null, $file->getFullUrl() ) . "\n" . |
| 648 | + " " . Xml::element( 'src', null, $file->getCanonicalUrl() ) . "\n" . |
649 | 649 | " " . Xml::element( 'size', null, $file->getSize() ) . "\n" . |
650 | 650 | " " . Xml::element( 'sha1base36', null, $file->getSha1() ) . "\n" . |
651 | 651 | " " . Xml::element( 'rel', null, $file->getRel() ) . "\n" . |
Index: branches/REL1_18/phase3/includes/OutputPage.php |
— | — | @@ -1847,7 +1847,7 @@ |
1848 | 1848 | |
1849 | 1849 | if ( $this->mRedirect != '' ) { |
1850 | 1850 | # Standards require redirect URLs to be absolute |
1851 | | - $this->mRedirect = wfExpandUrl( $this->mRedirect ); |
| 1851 | + $this->mRedirect = wfExpandUrl( $this->mRedirect, PROTO_CURRENT ); |
1852 | 1852 | if( $this->mRedirectCode == '301' || $this->mRedirectCode == '303' ) { |
1853 | 1853 | if( !$wgDebugRedirects ) { |
1854 | 1854 | $message = HttpStatus::getMessage( $this->mRedirectCode ); |
— | — | @@ -2829,8 +2829,8 @@ |
2830 | 2830 | } else { |
2831 | 2831 | $tags[] = Html::element( 'link', array( |
2832 | 2832 | 'rel' => 'canonical', |
2833 | | - 'href' => wfExpandUrl( $this->getTitle()->getFullURL(), PROTO_HTTP ) ) |
2834 | | - ); |
| 2833 | + 'href' => $this->getTitle()->getCanonicalUrl() |
| 2834 | + ) ); |
2835 | 2835 | } |
2836 | 2836 | } |
2837 | 2837 | |
Property changes on: branches/REL1_18/phase3/includes/OutputPage.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
2838 | 2838 | Merged /trunk/phase3/includes/OutputPage.php:r94737,94990,95000-95002,95006-95007,95010-95011,95894 |
Index: branches/REL1_18/phase3/includes/actions/RevertAction.php |
— | — | @@ -96,7 +96,9 @@ |
97 | 97 | 'raw' => true, |
98 | 98 | 'default' => wfMsgExt( 'filerevert-intro', 'parse', $this->getTitle()->getText(), |
99 | 99 | $this->getLang()->date( $timestamp, true ), $this->getLang()->time( $timestamp, true ), |
100 | | - wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ) ) ) |
| 100 | + wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ), |
| 101 | + PROTO_CURRENT |
| 102 | + ) ) |
101 | 103 | ), |
102 | 104 | 'comment' => array( |
103 | 105 | 'type' => 'text', |
— | — | @@ -119,7 +121,9 @@ |
120 | 122 | $this->getOutput()->addHTML( wfMsgExt( 'filerevert-success', 'parse', $this->getTitle()->getText(), |
121 | 123 | $this->getLang()->date( $timestamp, true ), |
122 | 124 | $this->getLang()->time( $timestamp, true ), |
123 | | - wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ) ) ) ); |
| 125 | + wfExpandUrl( $this->page->getFile()->getArchiveUrl( $this->getRequest()->getText( 'oldimage' ) ), |
| 126 | + PROTO_CURRENT |
| 127 | + ) ) ); |
124 | 128 | $this->getOutput()->returnToMain( false, $this->getTitle() ); |
125 | 129 | } |
126 | 130 | |
Index: branches/REL1_18/phase3/includes/api/ApiQuerySiteinfo.php |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | $data = array(); |
119 | 119 | $mainPage = Title::newMainPage(); |
120 | 120 | $data['mainpage'] = $mainPage->getPrefixedText(); |
121 | | - $data['base'] = wfExpandUrl( $mainPage->getFullUrl() ); |
| 121 | + $data['base'] = wfExpandUrl( $mainPage->getFullUrl(), PROTO_CURRENT ); |
122 | 122 | $data['sitename'] = $GLOBALS['wgSitename']; |
123 | 123 | $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}"; |
124 | 124 | $data['phpversion'] = phpversion(); |
— | — | @@ -284,9 +284,13 @@ |
285 | 285 | if ( isset( $langNames[$row->iw_prefix] ) ) { |
286 | 286 | $val['language'] = $langNames[$row->iw_prefix]; |
287 | 287 | } |
288 | | - $val['url'] = wfExpandUrl( $row->iw_url ); |
289 | | - $val['wikiid'] = $row->iw_wikiid; |
290 | | - $val['api'] = $row->iw_api; |
| 288 | + $val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT ); |
| 289 | + if( isset( $row['iw_wikiid'] ) ) { |
| 290 | + $val['wikiid'] = $row['iw_wikiid']; |
| 291 | + } |
| 292 | + if( isset( $row['iw_api'] ) ) { |
| 293 | + $val['api'] = $row['iw_api']; |
| 294 | + } |
291 | 295 | |
292 | 296 | $data[] = $val; |
293 | 297 | } |
— | — | @@ -448,7 +452,7 @@ |
449 | 453 | protected function appendRightsInfo( $property ) { |
450 | 454 | global $wgRightsPage, $wgRightsUrl, $wgRightsText; |
451 | 455 | $title = Title::newFromText( $wgRightsPage ); |
452 | | - $url = $title ? wfExpandUrl( $title->getFullURL() ) : $wgRightsUrl; |
| 456 | + $url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ) : $wgRightsUrl; |
453 | 457 | $text = $wgRightsText; |
454 | 458 | if ( !$text && $title ) { |
455 | 459 | $text = $title->getPrefixedText(); |
Index: branches/REL1_18/phase3/includes/api/ApiParse.php |
— | — | @@ -353,7 +353,7 @@ |
354 | 354 | |
355 | 355 | $entry['lang'] = $bits[0]; |
356 | 356 | if ( $title ) { |
357 | | - $entry['url'] = wfExpandUrl( $title->getFullURL() ); |
| 357 | + $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); |
358 | 358 | } |
359 | 359 | $this->getResult()->setContent( $entry, $bits[1] ); |
360 | 360 | $result[] = $entry; |
— | — | @@ -435,7 +435,7 @@ |
436 | 436 | |
437 | 437 | $title = Title::newFromText( "{$prefix}:{$title}" ); |
438 | 438 | if ( $title ) { |
439 | | - $entry['url'] = wfExpandUrl( $title->getFullURL() ); |
| 439 | + $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); |
440 | 440 | } |
441 | 441 | |
442 | 442 | $this->getResult()->setContent( $entry, $title->getFullText() ); |
Index: branches/REL1_18/phase3/includes/api/ApiQuery.php |
— | — | @@ -374,7 +374,7 @@ |
375 | 375 | ); |
376 | 376 | if ( $this->iwUrl ) { |
377 | 377 | $title = Title::newFromText( $rawTitleStr ); |
378 | | - $item['url'] = wfExpandUrl( $title->getFullURL() ); |
| 378 | + $item['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); |
379 | 379 | } |
380 | 380 | $intrwValues[] = $item; |
381 | 381 | } |
Index: branches/REL1_18/phase3/includes/api/ApiQueryIWLinks.php |
— | — | @@ -112,7 +112,7 @@ |
113 | 113 | if ( !is_null( $params['url'] ) ) { |
114 | 114 | $title = Title::newFromText( "{$row->iwl_prefix}:{$row->iwl_title}" ); |
115 | 115 | if ( $title ) { |
116 | | - $entry['url'] = wfExpandUrl( $title->getFullURL() ); |
| 116 | + $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); |
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
Index: branches/REL1_18/phase3/includes/api/ApiQueryLangLinks.php |
— | — | @@ -106,7 +106,7 @@ |
107 | 107 | if ( $params['url'] ) { |
108 | 108 | $title = Title::newFromText( "{$row->ll_lang}:{$row->ll_title}" ); |
109 | 109 | if ( $title ) { |
110 | | - $entry['url'] = wfExpandUrl( $title->getFullURL() ); |
| 110 | + $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); |
111 | 111 | } |
112 | 112 | } |
113 | 113 | ApiResult::setContent( $entry, $row->ll_title ); |
Index: branches/REL1_18/phase3/includes/api/ApiQueryImageInfo.php |
— | — | @@ -348,7 +348,7 @@ |
349 | 349 | if ( !is_null( $thumbParams ) ) { |
350 | 350 | $mto = $file->transform( $thumbParams ); |
351 | 351 | if ( $mto && !$mto->isError() ) { |
352 | | - $vals['thumburl'] = wfExpandUrl( $mto->getUrl() ); |
| 352 | + $vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT ); |
353 | 353 | |
354 | 354 | // bug 23834 - If the URL's are the same, we haven't resized it, so shouldn't give the wanted |
355 | 355 | // thumbnail sizes for the thumbnail actual size |
— | — | @@ -370,8 +370,8 @@ |
371 | 371 | $vals['thumberror'] = $mto->toText(); |
372 | 372 | } |
373 | 373 | } |
374 | | - $vals['url'] = wfExpandUrl( $file->getFullURL() ); |
375 | | - $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl() ); |
| 374 | + $vals['url'] = wfExpandUrl( $file->getFullURL(), PROTO_CURRENT ); |
| 375 | + $vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl(), PROTO_CURRENT ); |
376 | 376 | } |
377 | 377 | |
378 | 378 | if ( $sha1 ) { |
Property changes on: branches/REL1_18/phase3/includes/api/ApiQueryImageInfo.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
379 | 379 | Merged /trunk/phase3/includes/api/ApiQueryImageInfo.php:r94737,94990,95000-95002,95006-95007,95010-95011,95894 |
Index: branches/REL1_18/phase3/includes/api/ApiRsd.php |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | $service = array( 'apis' => $this->formatRsdApiList() ); |
50 | 50 | ApiResult::setContent( $service, 'MediaWiki', 'engineName' ); |
51 | 51 | ApiResult::setContent( $service, 'http://www.mediawiki.org/', 'engineLink' ); |
52 | | - ApiResult::setContent( $service, wfExpandUrl( Title::newMainPage()->getFullURL() ), 'homePageLink' ); |
| 52 | + ApiResult::setContent( $service, Title::newMainPage()->getCanonicalUrl(), 'homePageLink' ); |
53 | 53 | |
54 | 54 | $result->setIndexedTagName( $service['apis'], 'api' ); |
55 | 55 | |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | $apis = array( |
100 | 100 | 'MediaWiki' => array( |
101 | 101 | // The API link is required for all RSD API entries. |
102 | | - 'apiLink' => wfExpandUrl( wfScript( 'api' ) ), |
| 102 | + 'apiLink' => wfExpandUrl( wfScript( 'api' ), PROTO_CURRENT ), |
103 | 103 | |
104 | 104 | // Docs link is optional, but recommended. |
105 | 105 | 'docs' => 'http://www.mediawiki.org/wiki/API', |
Index: branches/REL1_18/phase3/includes/api/ApiQueryInfo.php |
— | — | @@ -380,8 +380,8 @@ |
381 | 381 | } |
382 | 382 | |
383 | 383 | if ( $this->fld_url ) { |
384 | | - $pageInfo['fullurl'] = wfExpandUrl( $title->getFullURL() ); |
385 | | - $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ) ); |
| 384 | + $pageInfo['fullurl'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); |
| 385 | + $pageInfo['editurl'] = wfExpandUrl( $title->getFullURL( 'action=edit' ), PROTO_CURRENT ); |
386 | 386 | } |
387 | 387 | if ( $this->fld_readable && $title->userCanRead() ) { |
388 | 388 | $pageInfo['readable'] = ''; |
Index: branches/REL1_18/phase3/includes/Title.php |
— | — | @@ -1013,6 +1013,10 @@ |
1014 | 1014 | * Get the URL form for an internal link. |
1015 | 1015 | * - Used in various Squid-related code, in case we have a different |
1016 | 1016 | * internal hostname for the server from the exposed one. |
| 1017 | + * |
| 1018 | + * This uses $wgInternalServer to qualify the path, or $wgServer |
| 1019 | + * if $wgInternalServer is not set. If the server variable used is |
| 1020 | + * protocol-relative, the URL will be expanded to http:// |
1017 | 1021 | * |
1018 | 1022 | * @param $query String an optional query string |
1019 | 1023 | * @param $variant String language variant of url (for sr, zh..) |
— | — | @@ -1021,7 +1025,7 @@ |
1022 | 1026 | public function getInternalURL( $query = '', $variant = false ) { |
1023 | 1027 | global $wgInternalServer, $wgServer; |
1024 | 1028 | $server = $wgInternalServer !== false ? $wgInternalServer : $wgServer; |
1025 | | - $url = $server . $this->getLocalURL( $query, $variant ); |
| 1029 | + $url = wfExpandUrl( $server . $this->getLocalURL( $query, $variant ), PROTO_HTTP ); |
1026 | 1030 | wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query ) ); |
1027 | 1031 | return $url; |
1028 | 1032 | } |
Property changes on: branches/REL1_18/phase3/includes/Title.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1029 | 1033 | Merged /trunk/phase3/includes/Title.php:r94737,94990,95000-95002,95006-95007,95010-95011,95894 |
Index: branches/REL1_18/phase3/includes/FileDeleteForm.php |
— | — | @@ -256,7 +256,7 @@ |
257 | 257 | wfEscapeWikiText( $this->title->getText() ), |
258 | 258 | $wgLang->date( $this->getTimestamp(), true ), |
259 | 259 | $wgLang->time( $this->getTimestamp(), true ), |
260 | | - wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ) ) ); |
| 260 | + wfExpandUrl( $this->file->getArchiveUrl( $this->oldimage ), PROTO_CURRENT ) ); |
261 | 261 | } else { |
262 | 262 | return wfMsgExt( |
263 | 263 | $message, |
Index: branches/REL1_18/phase3/includes/DefaultSettings.php |
— | — | @@ -1741,9 +1741,9 @@ |
1742 | 1742 | $wgUseXVO = false; |
1743 | 1743 | |
1744 | 1744 | /** Add X-Forwarded-Proto to the Vary and X-Vary-Options headers for API |
1745 | | - * requests. Use this if you have an SSL termination setup and want to split |
1746 | | - * the cache between HTTP and HTTPS for API requests. This does not affect |
1747 | | - * 'regular' requests. |
| 1745 | + * requests and RSS/Atom feeds. Use this if you have an SSL termination setup |
| 1746 | + * and need to split the cache between HTTP and HTTPS for API and feed requests |
| 1747 | + * in order to prevent cache pollution. This does not affect 'normal' requests. |
1748 | 1748 | */ |
1749 | 1749 | $wgVaryOnXFPForAPI = false; |
1750 | 1750 | |
Index: branches/REL1_18/phase3/includes/specials/SpecialSearch.php |
— | — | @@ -28,7 +28,14 @@ |
29 | 29 | * @ingroup SpecialPage |
30 | 30 | */ |
31 | 31 | class SpecialSearch extends SpecialPage { |
32 | | - /// Current search profile |
| 32 | + /** |
| 33 | + * Current search profile. Search profile is just a name that identifies |
| 34 | + * the active search tab on the search page (content, help, discussions...) |
| 35 | + * For users tt replaces the set of enabled namespaces from the query |
| 36 | + * string when applicable. Extensions can add new profiles with hooks |
| 37 | + * with custom search options just for that profile. |
| 38 | + * null|string |
| 39 | + */ |
33 | 40 | protected $profile; |
34 | 41 | |
35 | 42 | /// Search engine |
— | — | @@ -743,13 +750,13 @@ |
744 | 751 | $out = ""; |
745 | 752 | // display project name |
746 | 753 | if(is_null($lastInterwiki) || $lastInterwiki != $t->getInterwiki()) { |
747 | | - if( key_exists($t->getInterwiki(),$customCaptions) ) |
| 754 | + if( array_key_exists($t->getInterwiki(),$customCaptions) ) { |
748 | 755 | // captions from 'search-interwiki-custom' |
749 | 756 | $caption = $customCaptions[$t->getInterwiki()]; |
750 | 757 | else{ |
751 | 758 | // default is to show the hostname of the other wiki which might suck |
752 | 759 | // if there are many wikis on one hostname |
753 | | - $parsed = parse_url($t->getFullURL()); |
| 760 | + $parsed = wfParseUrl( $t->getFullURL() ); |
754 | 761 | $caption = wfMsg('search-interwiki-default', $parsed['host']); |
755 | 762 | } |
756 | 763 | // "more results" link (special page stuff could be localized, but we might not know target lang) |
Index: branches/REL1_18/phase3/opensearch_desc.php |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | 'height' => 16, |
53 | 53 | 'width' => 16, |
54 | 54 | 'type' => 'image/x-icon' ), |
55 | | - wfExpandUrl( $wgFavicon ) ); |
| 55 | + wfExpandUrl( $wgFavicon , PROTO_CURRENT ) ); |
56 | 56 | |
57 | 57 | $urls = array(); |
58 | 58 | |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | $urls[] = array( |
64 | 64 | 'type' => 'text/html', |
65 | 65 | 'method' => 'get', |
66 | | - 'template' => $searchPage->getFullURL( 'search={searchTerms}' ) ); |
| 66 | + 'template' => $searchPage->getCanonicalURL( 'search={searchTerms}' ) ); |
67 | 67 | |
68 | 68 | if( $wgEnableAPI ) { |
69 | 69 | // JSON interface for search suggestions. |
— | — | @@ -86,6 +86,6 @@ |
87 | 87 | // sends you to the domain root if you hit "enter" with an empty |
88 | 88 | // search box. |
89 | 89 | print Xml::element( 'moz:SearchForm', null, |
90 | | - $searchPage->getFullUrl() ); |
| 90 | + $searchPage->getCanonicalURL() ); |
91 | 91 | |
92 | 92 | print '</OpenSearchDescription>'; |