(bug 4253) - recentchanges IRC:
authorAlex Z <mrzman@users.mediawiki.org>
Mon, 27 Oct 2008 22:41:17 +0000 (22:41 +0000)
committerAlex Z <mrzman@users.mediawiki.org>
Mon, 27 Oct 2008 22:41:17 +0000 (22:41 +0000)
* Don't include the title in diff ULRs
* If the message is still too long, trim the comment.

RELEASE-NOTES
includes/RecentChange.php

index 8f938c4..2632c39 100644 (file)
@@ -287,6 +287,8 @@ The following extensions are migrated into MediaWiki 1.14:
 * (bug 12764) Special:LonelyPages shows transcluded pages
 * (bug 16073) Enhanced RecentChanges uses onclick handler with better fallback if
   JavaScript is disabled.
+* (bug 4253) Recentchanges IRC messages no longer include title in diff URLs and
+  the comment is trimmed if necessary to maintain proper message length.
 
 === API changes in 1.14 ===
 
index 030db5c..31cdc0f 100644 (file)
@@ -613,8 +613,10 @@ class RecentChange
                        $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);
                }
 
                if( isset( $oldSize ) && isset( $newSize ) ) {
@@ -643,6 +645,20 @@ class RecentChange
                # no colour (\003) switches back to the term default
                $fullString = "\00314[[\00307$title\00314]]\0034 $flag\00310 " .
                              "\00302$url\003 \0035*\003 \00303$user\003 \0035*\003 $szdiff \00310$comment\003\n";
+               # RFC 2812 sets the limit for IRC message length at 512 bytes
+               # If the message is longer than that, trim the comment as much as necessary
+               # It might still be too long, but there's not much else we can trim without losing anything important
+               if ( strlen($fullString) > 512 ) {
+                       $extra = strlen($fullString) - 512;
+                       if ( strlen($comment) > $extra ) {
+                               $comment = substr($comment, 0, strlen($comment) - $extra);
+                       } else {
+                               $comment = '';
+                       }
+                       $fullString = "\00314[[\00307$title\00314]]\0034 $flag\00310 " .
+                                     "\00302$url\003 \0035*\003 \00303$user\003 \0035*\003 $szdiff \00310$comment\003\n";
+               }
+                       
                return $fullString;
        }