| Index: trunk/phase3/includes/RecentChange.php |
| — | — | @@ -682,7 +682,8 @@ |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | public function getIRCLine() { |
| 686 | | - global $wgUseRCPatrol, $wgUseNPPatrol, $wgRC2UDPInterwikiPrefix, $wgLocalInterwiki; |
| | 686 | + global $wgUseRCPatrol, $wgUseNPPatrol, $wgRC2UDPInterwikiPrefix, $wgLocalInterwiki, |
| | 687 | + $wgCanonicalServer, $wgScript; |
| 687 | 688 | |
| 688 | 689 | if( $this->mAttribs['rc_type'] == RC_LOG ) { |
| 689 | 690 | $titleObj = Title::newFromText( 'Log/' . $this->mAttribs['rc_log_type'], NS_SPECIAL ); |
| — | — | @@ -695,19 +696,18 @@ |
| 696 | 697 | if( $this->mAttribs['rc_type'] == RC_LOG ) { |
| 697 | 698 | $url = ''; |
| 698 | 699 | } else { |
| | 700 | + $url = $wgCanonicalServer . $wgScript; |
| 699 | 701 | if( $this->mAttribs['rc_type'] == RC_NEW ) { |
| 700 | | - $url = 'oldid=' . $this->mAttribs['rc_this_oldid']; |
| | 702 | + $query = '?oldid=' . $this->mAttribs['rc_this_oldid']; |
| 701 | 703 | } else { |
| 702 | | - $url = 'diff=' . $this->mAttribs['rc_this_oldid'] . '&oldid=' . $this->mAttribs['rc_last_oldid']; |
| | 704 | + $query = '?diff=' . $this->mAttribs['rc_this_oldid'] . '&oldid=' . $this->mAttribs['rc_last_oldid']; |
| 703 | 705 | } |
| 704 | 706 | if ( $wgUseRCPatrol || ( $this->mAttribs['rc_type'] == RC_NEW && $wgUseNPPatrol ) ) { |
| 705 | | - $url .= '&rcid=' . $this->mAttribs['rc_id']; |
| | 707 | + $query .= '&rcid=' . $this->mAttribs['rc_id']; |
| 706 | 708 | } |
| 707 | | - // XXX: *HACK* this should use getFullURL(), hacked for SSL madness --brion 2005-12-26 |
| 708 | | - // XXX: *HACK^2* the preg_replace() undoes much of what getInternalURL() does, but we |
| 709 | | - // XXX: need to call it so that URL paths on the Wikimedia secure server can be fixed |
| 710 | | - // XXX: by a custom GetInternalURL hook --vyznev 2008-12-10 |
| 711 | | - $url = preg_replace( '/title=[^&]*&/', '', $titleObj->getInternalURL( $url ) ); |
| | 709 | + // HACK: We need this hook for WMF's secure server setup |
| | 710 | + wfRunHooks( 'IRCLineURL', array( &$url, &$query ) ); |
| | 711 | + $url .= $query; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | if( isset( $this->mExtra['oldSize'] ) && isset( $this->mExtra['newSize'] ) ) { |
| Index: trunk/phase3/includes/parser/CoreParserFunctions.php |
| — | — | @@ -35,6 +35,8 @@ |
| 36 | 36 | $parser->setFunctionHook( 'localurle', array( __CLASS__, 'localurle' ), SFH_NO_HASH ); |
| 37 | 37 | $parser->setFunctionHook( 'fullurl', array( __CLASS__, 'fullurl' ), SFH_NO_HASH ); |
| 38 | 38 | $parser->setFunctionHook( 'fullurle', array( __CLASS__, 'fullurle' ), SFH_NO_HASH ); |
| | 39 | + $parser->setFunctionHook( 'canonicalurl', array( __CLASS__, 'canonicalurl' ), SFH_NO_HASH ); |
| | 40 | + $parser->setFunctionHook( 'canonicalurle', array( __CLASS__, 'canonicalurle' ), SFH_NO_HASH ); |
| 39 | 41 | $parser->setFunctionHook( 'formatnum', array( __CLASS__, 'formatnum' ), SFH_NO_HASH ); |
| 40 | 42 | $parser->setFunctionHook( 'grammar', array( __CLASS__, 'grammar' ), SFH_NO_HASH ); |
| 41 | 43 | $parser->setFunctionHook( 'gender', array( __CLASS__, 'gender' ), SFH_NO_HASH ); |
| — | — | @@ -218,6 +220,8 @@ |
| 219 | 221 | static function localurle( $parser, $s = '', $arg = null ) { return self::urlFunction( 'escapeLocalURL', $s, $arg ); } |
| 220 | 222 | static function fullurl( $parser, $s = '', $arg = null ) { return self::urlFunction( 'getFullURL', $s, $arg ); } |
| 221 | 223 | static function fullurle( $parser, $s = '', $arg = null ) { return self::urlFunction( 'escapeFullURL', $s, $arg ); } |
| | 224 | + static function canonicalurl( $parser, $s = '', $arg = null ) { return self::urlFunction( 'getCanonicalURL', $s, $arg ); } |
| | 225 | + static function canonicalurle( $parser, $s = '', $arg = null ) { return self::urlFunction( 'escapeCanonicalURL', $s, $arg ); } |
| 222 | 226 | |
| 223 | 227 | static function urlFunction( $func, $s = '', $arg = null ) { |
| 224 | 228 | $title = Title::newFromText( $s ); |
| Index: trunk/phase3/includes/Setup.php |
| — | — | @@ -343,6 +343,11 @@ |
| 344 | 344 | wfProfileOut( $fname . '-includes' ); |
| 345 | 345 | } |
| 346 | 346 | |
| | 347 | +# Now that GlobalFunctions is loaded, set the default for $wgCanonicalServer |
| | 348 | +if ( $wgCanonicalServer === false ) { |
| | 349 | + $wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP ); |
| | 350 | +} |
| | 351 | + |
| 347 | 352 | wfProfileIn( $fname . '-misc1' ); |
| 348 | 353 | |
| 349 | 354 | # Raise the memory limit if it's too low |
| Index: trunk/phase3/includes/Title.php |
| — | — | @@ -987,6 +987,13 @@ |
| 988 | 988 | public function escapeFullURL( $query = '' ) { |
| 989 | 989 | return htmlspecialchars( $this->getFullURL( $query ) ); |
| 990 | 990 | } |
| | 991 | + |
| | 992 | + /** |
| | 993 | + * HTML-escaped version of getCanonicalURL() |
| | 994 | + */ |
| | 995 | + public function escapeCanonicalURL( $query = '', $variant = false ) { |
| | 996 | + return htmlspecialchars( $this->getCanonicalURL( $query, $variant ) ); |
| | 997 | + } |
| 991 | 998 | |
| 992 | 999 | /** |
| 993 | 1000 | * Get the URL form for an internal link. |
| — | — | @@ -1010,6 +1017,22 @@ |
| 1011 | 1018 | } |
| 1012 | 1019 | |
| 1013 | 1020 | /** |
| | 1021 | + * Get the URL for a canonical link, for use in things like IRC and |
| | 1022 | + * e-mail notifications. Uses $wgCanonicalServer and the |
| | 1023 | + * GetCanonicalURL hook. |
| | 1024 | + * |
| | 1025 | + * @param $query string An optional query string |
| | 1026 | + * @param $variant string Language variant of URL (for sr, zh, ...) |
| | 1027 | + * @return string The URL |
| | 1028 | + */ |
| | 1029 | + public function getCanonicalURL( $query = '', $variant = false ) { |
| | 1030 | + global $wgCanonicalServer; |
| | 1031 | + $url = $wgCanonicalServer . $this->getLocalURL( $query, $variant ); |
| | 1032 | + wfRunHooks( 'GetCanonicalURL', array( &$this, &$url, $query ) ); |
| | 1033 | + return $url; |
| | 1034 | + } |
| | 1035 | + |
| | 1036 | + /** |
| 1014 | 1037 | * Get the edit URL for this Title |
| 1015 | 1038 | * |
| 1016 | 1039 | * @return String the URL, or a null string if this is an |
| Index: trunk/phase3/includes/DefaultSettings.php |
| — | — | @@ -39,19 +39,31 @@ |
| 40 | 40 | $wgSitename = 'MediaWiki'; |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | | - * URL of the server. It will be automatically built including https mode. |
| | 43 | + * URL of the server. |
| 44 | 44 | * |
| 45 | 45 | * Example: |
| 46 | 46 | * <code> |
| 47 | | - * $wgServer = http://example.com |
| | 47 | + * $wgServer = 'http://example.com'; |
| 48 | 48 | * </code> |
| 49 | 49 | * |
| 50 | 50 | * This is usually detected correctly by MediaWiki. If MediaWiki detects the |
| 51 | 51 | * wrong server, it will redirect incorrectly after you save a page. In that |
| 52 | 52 | * case, set this variable to fix it. |
| | 53 | + * |
| | 54 | + * If you want to use protocol-relative URLs on your wiki, set this to a |
| | 55 | + * protocol-relative URL like '//example.com' and set $wgCanonicalServer |
| | 56 | + * to a fully qualified URL. |
| 53 | 57 | */ |
| 54 | 58 | $wgServer = WebRequest::detectServer(); |
| 55 | 59 | |
| | 60 | +/** |
| | 61 | + * Canonical URL of the server, to use in IRC feeds and notification e-mails. |
| | 62 | + * Must be fully qualified, even if $wgServer is protocol-relative. |
| | 63 | + * |
| | 64 | + * Defaults to $wgServer, expanded to a fully qualified http:// URL if needed. |
| | 65 | + */ |
| | 66 | +$wgCanonicalServer = false; |
| | 67 | + |
| 56 | 68 | /************************************************************************//** |
| 57 | 69 | * @name Script path settings |
| 58 | 70 | * @{ |
| — | — | @@ -120,6 +132,7 @@ |
| 121 | 133 | */ |
| 122 | 134 | $wgLoadScript = false; |
| 123 | 135 | |
| | 136 | + |
| 124 | 137 | /**@}*/ |
| 125 | 138 | |
| 126 | 139 | /************************************************************************//** |
| Index: trunk/phase3/languages/messages/MessagesEn.php |
| — | — | @@ -310,6 +310,8 @@ |
| 311 | 311 | 'plural' => array( 0, 'PLURAL:' ), |
| 312 | 312 | 'fullurl' => array( 0, 'FULLURL:' ), |
| 313 | 313 | 'fullurle' => array( 0, 'FULLURLE:' ), |
| | 314 | + 'canonicalurl' => array( 0, 'CANONICALURL:' ), |
| | 315 | + 'canonicalurle' => array( 0, 'CANONICALURLE:' ), |
| 314 | 316 | 'lcfirst' => array( 0, 'LCFIRST:' ), |
| 315 | 317 | 'ucfirst' => array( 0, 'UCFIRST:' ), |
| 316 | 318 | 'lc' => array( 0, 'LC:' ), |
| — | — | @@ -2772,16 +2774,16 @@ |
| 2773 | 2775 | |
| 2774 | 2776 | -- |
| 2775 | 2777 | To change your email notification settings, visit |
| 2776 | | -{{fullurl:{{#special:Preferences}}}} |
| | 2778 | +{{canonicalurl:{{#special:Preferences}}}} |
| 2777 | 2779 | |
| 2778 | 2780 | To change your watchlist settings, visit |
| 2779 | | -{{fullurl:{{#special:EditWatchlist}}}} |
| | 2781 | +{{canonicalurl:{{#special:EditWatchlist}}}} |
| 2780 | 2782 | |
| 2781 | 2783 | To delete the page from your watchlist, visit |
| 2782 | 2784 | $UNWATCHURL |
| 2783 | 2785 | |
| 2784 | 2786 | Feedback and further assistance: |
| 2785 | | -{{fullurl:{{MediaWiki:Helppage}}}}', |
| | 2787 | +{{canonicalurl:{{MediaWiki:Helppage}}}}', |
| 2786 | 2788 | |
| 2787 | 2789 | # Delete |
| 2788 | 2790 | 'deletepage' => 'Delete page', |