* Made the show change size function work on page moves, page creations, and
authorLeon Weber <leon@users.mediawiki.org>
Wed, 13 Dec 2006 20:08:02 +0000 (20:08 +0000)
committerLeon Weber <leon@users.mediawiki.org>
Wed, 13 Dec 2006 20:08:02 +0000 (20:08 +0000)
  log entries.
* Also fixed it in the javascript recentchanges.
* Moved the value behind the page title to ensure the columns are still lined up
* Merged both sql patches into one.
* Set the default for both columns to NULL to make it work on edits before the db
  update.

RELEASE-NOTES
includes/ChangesList.php
includes/RecentChange.php
maintenance/archives/patch-rc_len.sql [new file with mode: 0644]
maintenance/archives/patch-rc_new_len.sql [deleted file]
maintenance/archives/patch-rc_old_len.sql [deleted file]
maintenance/updaters.inc

index 50d381c..49605bf 100644 (file)
@@ -301,6 +301,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   after the password is reset, for instance by e-mail.
 * (bug 6394) Invalidate the password set for "by e-mail" account creations
   to avoid accidental empty password creations.
+* Made the show change size function work on page moves, page creations, and 
+  log entries. Also fixed it in the javascript recentchanges.
 
 
 == Languages updated ==
index c918de9..ede27ce 100644 (file)
@@ -255,10 +255,6 @@ class OldChangesList extends ChangesList {
 
                        $this->insertDiffHist($s, $rc, $unpatrolled);
 
-                       if( $wgRCShowChangedSize ) {
-                               $s .= $rc->getCharacterDifference() . ' . . ';
-                       }
-
                        # M, N, b and ! (minor, new, bot and unpatrolled)
                        $s .= ' ' . $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $unpatrolled, '', $rc_bot );
                        $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
@@ -269,6 +265,11 @@ class OldChangesList extends ChangesList {
                wfProfileIn( $fname.'-rest' );
 
                $this->insertTimestamp($s,$rc);
+
+               if( $wgRCShowChangedSize ) {
+                       $s .= ( $rc->getCharacterDifference() == '' ? '' : $rc->getCharacterDifference() . ' . . ' );
+               }
+
                $this->insertUserRelatedLinks($s,$rc);
                $this->insertComment($s, $rc);
 
@@ -294,7 +295,7 @@ class EnhancedChangesList extends ChangesList {
         * Format a line for enhanced recentchange (aka with javascript and block of lines).
         */
        function recentChangesLine( &$baseRC, $watched = false ) {
-               global $wgLang, $wgContLang, $wgRCShowChangedSize;
+               global $wgLang, $wgContLang;
 
                # Create a specialised object
                $rc = RCCacheEntry::newFromParent( $baseRC );
@@ -343,12 +344,7 @@ class EnhancedChangesList extends ChangesList {
                        $clink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '' );
                }
 
-               $time = $wgContLang->time( $rc_timestamp, true, true );
-               # Character diff
-               if( $wgRCShowChangedSize ) {
-                       $time .= '&nbsp;' . $rc->getCharacterDifference();
-               }
-               $time .= '</tt> ';
+               $time = $wgContLang->time( $rc_timestamp, true, true ) . '</tt> ';
                $rc->watched = $watched;
                $rc->link = $clink;
                $rc->timestamp = $time;
@@ -472,13 +468,23 @@ class EnhancedChangesList extends ChangesList {
                if( $block[0]->mAttribs['rc_type'] != RC_LOG ) {
                        # Changes
                        $r .= ' ('.count($block).' ';
+
                        if( $isnew ) {
                                $r .= $this->message['changes'];
                        } else {
                                $r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
                                        $this->message['changes'], $curIdEq."&diff=$currentRevision&oldid=$oldid" );
                        }
-                       $r .= '; ';
+
+                       # Character difference
+                       $chardiff = $rcObj->getCharacterDifference( $block[ count( $block ) - 1 ]->mAttribs['rc_old_len'],
+                                       $block[0]->mAttribs['rc_new_len'] );
+                       if( $chardiff == '' ) {
+                               $r .= '; ';
+                       } else {
+                               $r .= '; ' . $chardiff . ' ';
+                       }
+                       
 
                        # History
                        $r .= $this->skin->makeKnownLinkObj( $block[0]->getTitle(),
@@ -521,7 +527,14 @@ class EnhancedChangesList extends ChangesList {
                        $r .= $rcObj->curlink;
                        $r .= '; ';
                        $r .= $rcObj->lastlink;
-                       $r .= ') . . '.$rcObj->userlink;
+                       $r .= ') . . ';
+
+                       # Character diff
+                       if( $wgRCShowChangedSize ) {
+                               $r .= ( $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . ' ) ;
+                       }
+
+                       $r .= $rcObj->userlink;
                        $r .= $rcObj->usertalklink;
                        $r .= $this->skin->commentBlock( $rc_comment, $rcObj->getTitle() );
                        $r .= "<br />\n";
@@ -591,7 +604,7 @@ class EnhancedChangesList extends ChangesList {
         * @return string a HTML formated line (generated using $r)
         */
        function recentChangesBlockLine( $rcObj ) {
-               global $wgContLang;
+               global $wgContLang, $wgRCShowChangedSize;
 
                # Get rc_xxxx variables
                extract( $rcObj->mAttribs );
@@ -619,10 +632,15 @@ class EnhancedChangesList extends ChangesList {
                $r .= ' ('. $rcObj->difflink .'; ';
 
                # Hist
-               $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' );
+               $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ') . . ';
+
+               # Character diff
+               if( $wgRCShowChangedSize ) {
+                       $r .= ( $rcObj->getCharacterDifference() == '' ? '' : '&nbsp;' . $rcObj->getCharacterDifference() . ' . . ' ) ;
+               }
 
                # User/talk
-               $r .= ') . . '.$rcObj->userlink . $rcObj->usertalklink;
+               $r .= $rcObj->userlink . $rcObj->usertalklink;
 
                # Comment
                if( $rc_type != RC_MOVE && $rc_type != RC_MOVE_OVER_REDIRECT ) {
index 098572c..465d1f2 100644 (file)
@@ -299,7 +299,9 @@ class RecentChange
                        'rc_moved_to_title' => '',
                        'rc_ip'             => $ip,
                        'rc_patrolled'      => 0,
-                       'rc_new'        => 1 # obsolete
+                       'rc_new'            => 1, # obsolete
+                       'rc_old_len'        => 0,
+                       'rc_new_len'        => $size
                );
 
                $rc->mExtra =  array(
@@ -342,8 +344,8 @@ class RecentChange
                        'rc_ip'         => $ip,
                        'rc_new'        => 0, # obsolete
                        'rc_patrolled'  => 1,
-                       'rc_old_len'    => 0,
-                       'rc_new_len'    => 0,
+                       'rc_old_len'    => NULL,
+                       'rc_new_len'    => NULL,
                );
 
                $rc->mExtra = array(
@@ -394,8 +396,8 @@ class RecentChange
                        'rc_ip' => $ip,
                        'rc_patrolled' => 1,
                        'rc_new'        => 0, # obsolete
-                       'rc_old_len'    => 0,
-                       'rc_new_len'    => 0,
+                       'rc_old_len'    => NULL,
+                       'rc_new_len'    => NULL,
                );
                $rc->mExtra =  array(
                        'prefixedDBkey' => $title->getPrefixedDBkey(),
@@ -440,8 +442,8 @@ class RecentChange
                        'rc_id' => $row->rc_id,
                        'rc_patrolled' => $row->rc_patrolled,
                        'rc_new' => $row->page_is_new, # obsolete
-                       'rc_old_len' => 0, # we can't get the text lengts from a cur row
-                       'rc_new_len' => 0,
+                       'rc_old_len' => NULL, # we can't get the text lengts from a cur row
+                       'rc_new_len' => NULL,
                );
 
                $this->mExtra = array();
@@ -533,18 +535,34 @@ class RecentChange
                return $fullString;
        }
 
-       function getCharacterDifference() {
-               global $wgRCChangedSizeThreshold;
-               $szdiff = $this->mAttribs['rc_new_len'] - $this->mAttribs['rc_old_len'];
+       /**
+        * Returns the change size (HTML).
+        * The lengths can be given optionally.
+        */
+       function getCharacterDifference( $old = 0, $new = 0 ) {
+               global $wgRCChangedSizeThreshold, $wgLang;
+
+               if( $old === 0 ) {
+                       $old = $this->mAttribs['rc_old_len'];
+               }
+               if( $new === 0 ) {
+                       $new = $this->mAttribs['rc_new_len'];
+               }
+
+               if( $old === NULL || $new === NULL ) {
+                       return '';
+               }
+
+               $szdiff = $new - $old;
 
                if( $szdiff < $wgRCChangedSizeThreshold ) {
-                       return "<span class='mw-plusminus-bold'>($szdiff)</span>";
+                       return '<span class=\'mw-plusminus-bold\'>(' . $wgLang->formatNum( $szdiff ) . '</span>';
                } elseif( $szdiff === 0 ) {
-                       return "<span class='mw-plusminus-null'>($szdiff)</span>";
+                       return '<span class=\'mw-plusminus-null\'>(' . $wgLang->formatNum( $szdiff ) . ')</span>';
                } elseif( $szdiff > 0 ) {
-                       return "<span class='mw-plusminus-pos'>(+$szdiff)</span>";
+                       return '<span class=\'mw-plusminus-pos\'>(+' . $wgLang->formatNum( $szdiff ) . ')</span>';
                } else {
-                       return "<span class='mw-pluminus-neg'>($szdiff)</span>";
+                       return '<span class=\'mw-pluminus-neg\'>(' . $wgLang->formatNum( $szdiff ) . ')</span>';
                }
        }
 }
diff --git a/maintenance/archives/patch-rc_len.sql b/maintenance/archives/patch-rc_len.sql
new file mode 100644 (file)
index 0000000..920f755
--- /dev/null
@@ -0,0 +1,9 @@
+--
+-- patch-rc_len.sql
+-- Adds two rows to recentchanges to hold the text size befor and after the edit
+-- 2006-12-03
+--
+
+ALTER TABLE /*$wgDBprefix*/recentchanges
+       ADD COLUMN rc_old_len int(10), ADD COLUMN rc_new_len int(10);
+
diff --git a/maintenance/archives/patch-rc_new_len.sql b/maintenance/archives/patch-rc_new_len.sql
deleted file mode 100644 (file)
index 6cdd48d..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
---
--- patch-rc_new_len.sql
--- Adds a row to recentchanges to hold the text size after the edit
--- 2006-12-03
---
-
-ALTER TABLE /*$wgDBprefix*/recentchanges
-       ADD COLUMN rc_new_len int(10) default 0;
-
diff --git a/maintenance/archives/patch-rc_old_len.sql b/maintenance/archives/patch-rc_old_len.sql
deleted file mode 100644 (file)
index 8b46ba3..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
---
--- patch-rc_old_len.sql
--- Adds a row to recentchanges to hold the text size before the edit
--- 2006-12-03
---
-
-ALTER TABLE /*$wgDBprefix*/recentchanges
-       ADD COLUMN rc_old_len int(10) default 0;
-
index 25a0223..81481ec 100644 (file)
@@ -43,8 +43,7 @@ $wgNewFields = array(
        array( 'recentchanges', 'rc_ip',            'patch-rc_ip.sql' ),
        array( 'recentchanges', 'rc_id',            'patch-rc_id.sql' ),
        array( 'recentchanges', 'rc_patrolled',     'patch-rc-patrol.sql' ),
-       array( 'recentchanges', 'rc_old_len',       'patch-rc_old_len.sql' ),
-       array( 'recentchanges', 'rc_new_len',       'patch-rc_new_len.sql' ),
+       array( 'recentchanges', 'rc_old_len',       'patch-rc_len.sql' ),
        array( 'user',          'user_real_name',   'patch-user-realname.sql' ),
        array( 'user',          'user_token',       'patch-user_token.sql' ),
        array( 'user',          'user_email_token', 'patch-user_email_token.sql' ),
@@ -1050,8 +1049,8 @@ CREATE INDEX querycachetwo_title      ON querycachetwo (qcc_type,qcc_namespace,q
 CREATE INDEX querycachetwo_titletwo   ON querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
 
 -- New columns for fancy recentchanges display
-ALTER TABLE recentchanges ADD rc_old_len INT DEFAULT 0;
-ALTER TABLE recentchanges ADD rc_new_len INT DEFAULT 0;
+ALTER TABLE recentchanges ADD rc_old_len INT;
+ALTER TABLE recentchanges ADD rc_new_len INT;
 
 -- Note this upgrade
 INSERT INTO mediawiki_version (type,mw_version,notes)