(bug 4253, bug 16586) Don't repeat titles of new pages in URLs in the RC->IRC feed...
authorIlmari Karonen <vyznev@users.mediawiki.org>
Wed, 10 Dec 2008 15:56:02 +0000 (15:56 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Wed, 10 Dec 2008 15:56:02 +0000 (15:56 +0000)
Also simplify URL construction: old code used to call Title::getInternalURL() to build the URLs and then undo most of the work with preg_replace().
(TODO: Maybe consider introducing new global $wgIRCLineURLPrefix to optionally override the $wgInternalServer.$wgScript prefix?)

RELEASE-NOTES
includes/RecentChange.php

index 4e8952c..8e4589e 100644 (file)
@@ -394,6 +394,8 @@ The following extensions are migrated into MediaWiki 1.14:
 * (bug 14268) SVG image sizes now extracted with proper XML parser
 * (bug 14365) RepoGroup::findFiles() no longer crashes if passed an invalid
   title via the API
+* (bug 4253, bug 16586) Revision ID is now given instead of title in URLs for
+  new pages in the recent changes IRC feed
 
 === API changes in 1.14 ===
 
index 10bc318..10834ba 100644 (file)
@@ -589,7 +589,8 @@ class RecentChange
        }
 
        protected function getIRCLine() {
-               global $wgUseRCPatrol, $wgUseNPPatrol, $wgRC2UDPInterwikiPrefix, $wgLocalInterwiki;
+               global $wgUseRCPatrol, $wgUseNPPatrol, $wgRC2UDPInterwikiPrefix, $wgLocalInterwiki,
+                       $wgInternalServer, $wgScript;
 
                // FIXME: Would be good to replace these 2 extract() calls with something more explicit
                // e.g. list ($rc_type, $rc_id) = array_values ($this->mAttribs); [or something like that]
@@ -604,19 +605,21 @@ class RecentChange
                $title = $titleObj->getPrefixedText();
                $title = self::cleanupForIRC( $title );
 
-               // FIXME: *HACK* these should be getFullURL(), hacked for SSL madness --brion 2005-12-26
+               // XXX: This used to call Title::getInternalURL() and then strip out the title, but that's
+               // a lot of complex code just to prepend two globals to a query string.  Simplified.
                if( $rc_type == RC_LOG ) {
                        $url = '';
-               } elseif( $rc_new && ($wgUseRCPatrol || $wgUseNPPatrol) ) {
-                       $url = $titleObj->getInternalURL("rcid=$rc_id");
-               } else if( $rc_new ) {
-                       $url = $titleObj->getInternalURL();
-               } else if( $wgUseRCPatrol ) {
-                       $url = $titleObj->getInternalURL("diff=$rc_this_oldid&oldid=$rc_last_oldid&rcid=$rc_id");
-                       $url = preg_replace('/title=[^&]*&/', '', $url);
                } else {
-                       $url = $titleObj->getInternalURL("diff=$rc_this_oldid&oldid=$rc_last_oldid");
-                       $url = preg_replace('/title=[^&]*&/', '', $url);
+                       // XXX: *HACK* this should use $wgServer, hacked for SSL madness --brion 2005-12-26
+                       $url = $wgInternalServer . $wgScript;
+                       if( $rc_type == RC_NEW ) {
+                               $url .= "?oldid=$rc_this_oldid";
+                       } else {
+                               $url .= "?diff=$rc_this_oldid&oldid=$rc_last_oldid";
+                       }
+                       if( $wgUseRCPatrol || ($rc_type == RC_NEW && $wgUseNPPatrol) ) {
+                               $url .= "&rcid=$rc_id";
+                       }
                }
 
                if( isset( $oldSize ) && isset( $newSize ) ) {