* DB schema change: added two columns (rc_old_len and rc_new_len) to the recentchange...
authorLeon Weber <leon@users.mediawiki.org>
Sat, 9 Dec 2006 11:36:35 +0000 (11:36 +0000)
committerLeon Weber <leon@users.mediawiki.org>
Sat, 9 Dec 2006 11:36:35 +0000 (11:36 +0000)
  the text lengths before and after the edit
* (bug 1085) Made Special:Recentchanges show the character difference between the changed revisions

15 files changed:
RELEASE-NOTES
includes/ChangesList.php
includes/DefaultSettings.php
includes/RecentChange.php
maintenance/archives/patch-rc_new_len.sql [new file with mode: 0644]
maintenance/archives/patch-rc_old_len.sql [new file with mode: 0644]
maintenance/mysql5/tables-binary.sql
maintenance/mysql5/tables.sql
maintenance/oracle/tables.sql
maintenance/postgres/tables.sql
maintenance/tables.sql
maintenance/updaters.inc
skins/chick/main.css
skins/monobook/main.css
skins/simple/main.css

index 85e66da..97d2bfc 100644 (file)
@@ -254,6 +254,10 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Added a configuration variable allowing the "break out of framesets" feature 
   to be switched on and off ($wgBreakFrames). Off by default.
 * Allow Xml::check() $attribs parameter to override 'value' attribute
+* DB schema change: added two columns (rc_old_len and rc_new_len) to the recentchanges table to store
+  the text lengths before and after the edit
+* (bug 1085) Made Special:Recentchanges show the character difference between the changed revisions
+
 
 
 == Languages updated ==
index 54b7981..c918de9 100644 (file)
@@ -212,8 +212,6 @@ class ChangesList {
                global $wgUseRCPatrol, $wgUser;
                return( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) );
        }
-
-
 }
 
 
@@ -225,12 +223,11 @@ class OldChangesList extends ChangesList {
         * Format a line using the old system (aka without any javascript).
         */
        function recentChangesLine( &$rc, $watched = false ) {
-               global $wgContLang;
+               global $wgContLang, $wgRCShowChangedSize;
 
                $fname = 'ChangesList::recentChangesLineOld';
                wfProfileIn( $fname );
 
-
                # Extract DB fields into local scope
                extract( $rc->mAttribs );
 
@@ -258,6 +255,10 @@ 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);
@@ -293,7 +294,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;
+               global $wgLang, $wgContLang, $wgRCShowChangedSize;
 
                # Create a specialised object
                $rc = RCCacheEntry::newFromParent( $baseRC );
@@ -343,6 +344,11 @@ class EnhancedChangesList extends ChangesList {
                }
 
                $time = $wgContLang->time( $rc_timestamp, true, true );
+               # Character diff
+               if( $wgRCShowChangedSize ) {
+                       $time .= '&nbsp;' . $rc->getCharacterDifference();
+               }
+               $time .= '</tt> ';
                $rc->watched = $watched;
                $rc->link = $clink;
                $rc->timestamp = $time;
@@ -403,7 +409,7 @@ class EnhancedChangesList extends ChangesList {
         * Enhanced RC group
         */
        function recentChangesBlockGroup( $block ) {
-               global $wgContLang;
+               global $wgContLang, $wgRCShowChangedSize;
                $r = '';
 
                # Collate list of users
@@ -456,7 +462,6 @@ class EnhancedChangesList extends ChangesList {
 
                # Timestamp
                $r .= ' '.$block[0]->timestamp.' ';
-               $r .= '</tt>';
 
                # Article link
                $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
index 74053b5..b295789 100644 (file)
@@ -1048,7 +1048,8 @@ $wgCacheEpoch = '20030516000000';
  * to ensure that client-side caches don't keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '32';
+$wgStyleVersion = '33';
+
 
 # Server-side caching:
 
@@ -1095,11 +1096,20 @@ $wgEnotifRevealEditorAddress    = false;        # UPO; reply-to address may be filled with
 $wgEnotifMinorEdits            = true; # UPO; false: "minor edits" on pages do not trigger notification mails.
 #                                                      # Attention: _every_ change on a user_talk page trigger a notification mail (if the user is not yet notified)
 
-
 /** Show watching users in recent changes, watchlist and page history views */
 $wgRCShowWatchingUsers                                 = false; # UPO
 /** Show watching users in Page views */
 $wgPageShowWatchingUsers                       = false;
+/** Show the amount of changed characters in recent changes */
+$wgRCShowChangedSize                           = true;
+
+/**
+ * If the difference between the character counts of the text
+ * before and after the edit is below that value, the value will be 
+ * highlighted on the RC page.
+ */
+$wgRCChangedSizeThreshold                      = -500;
+
 /**
  * Show "Updated (since my last visit)" marker in RC view, watchlist and history
  * view for watched pages with new changes */
index d1cda39..781d74c 100644 (file)
@@ -24,6 +24,8 @@
  *     rc_ip           IP address of the user in dotted quad notation
  *     rc_new          obsolete, use rc_type==RC_NEW
  *     rc_patrolled    boolean whether or not someone has marked this edit as patrolled
+ *     rc_old_len      integer character count of the text before the edit
+ *     rc_new_len      the same after the edit
  *
  * mExtra:
  *     prefixedDBkey   prefixed db key, used by external app via msg queue
@@ -212,6 +214,7 @@ class RecentChange
                $oldId, $lastTimestamp, $bot = "default", $ip = '', $oldSize = 0, $newSize = 0,
                $newId = 0)
        {
+
                if ( $bot === 'default' ) {
                        $bot = $user->isAllowed( 'bot' );
                }
@@ -240,9 +243,11 @@ class RecentChange
                        'rc_bot'        => $bot ? 1 : 0,
                        'rc_moved_to_ns'        => 0,
                        'rc_moved_to_title'     => '',
-                       'rc_ip' => $ip,
-                       'rc_patrolled' => 0,
-                       'rc_new'        => 0 # obsolete
+                       'rc_ip'         => $ip,
+                       'rc_patrolled'  => 0,
+                       'rc_new'        => 0,  # obsolete
+                       'rc_old_len'    => $oldSize,
+                       'rc_new_len'    => $newSize
                );
 
                $rc->mExtra =  array(
@@ -522,5 +527,19 @@ class RecentChange
                return $fullString;
        }
 
+       function getCharacterDifference() {
+               global $wgRCChangedSizeThreshold;
+               $szdiff = $this->mAttribs['rc_new_len'] - $this->mAttribs['rc_old_len'];
+
+               if( $szdiff < $wgRCChangedSizeThreshold ) {
+                       return "<span class='mw-plusminus-big'>($szdiff)</span>";
+               } elseif( $szdiff === 0 ) {
+                       return "<span class='mw-plusminus-null'>($szdiff)</span>";
+               } elseif( $szdiff > 0 ) {
+                       return "<span class='mw-plusminus-pos'>(+$szdiff)</span>";
+               } else {
+                       return "<span class='mw-pluminus-neg'>($szdiff)</span>";
+               }
+       }
 }
 ?>
diff --git a/maintenance/archives/patch-rc_new_len.sql b/maintenance/archives/patch-rc_new_len.sql
new file mode 100644 (file)
index 0000000..6cdd48d
--- /dev/null
@@ -0,0 +1,9 @@
+--
+-- 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
new file mode 100644 (file)
index 0000000..8b46ba3
--- /dev/null
@@ -0,0 +1,9 @@
+--
+-- 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 0d5dc3f..d9caafa 100644 (file)
@@ -820,6 +820,11 @@ CREATE TABLE /*$wgDBprefix*/recentchanges (
   -- $wgPutIPinRC option is enabled.
   rc_ip char(15) NOT NULL default '',
   
+  -- Text length in characters before
+  -- and after the edit
+  rc_old_len int(10) default '0',
+  rc_new_len int(10) default '0',
+  
   PRIMARY KEY rc_id (rc_id),
   INDEX rc_timestamp (rc_timestamp),
   INDEX rc_namespace_title (rc_namespace, rc_title),
index ed8c684..cc624ba 100644 (file)
@@ -811,6 +811,11 @@ CREATE TABLE /*$wgDBprefix*/recentchanges (
   -- $wgPutIPinRC option is enabled.
   rc_ip char(15) NOT NULL default '',
   
+  -- Text length in characters before
+  -- and after the edit
+  rc_old_len int(10) default '0',
+  rc_new_len int(10) default '0',
+  
   PRIMARY KEY rc_id (rc_id),
   INDEX rc_timestamp (rc_timestamp),
   INDEX rc_namespace_title (rc_namespace, rc_title),
index 7b24d1e..030f427 100644 (file)
@@ -229,6 +229,8 @@ CREATE TABLE recentchanges (
        rc_moved_to_title       VARCHAR2(255),
        rc_patrolled    NUMBER(3) DEFAULT 0 NOT NULL,
        rc_ip           VARCHAR2(40),
+       rc_old_len      NUMBER(10) DEFAULT 0,
+       rc_new_len      NUMBER(10) DEFAULT 0,
        CONSTRAINT rc_pk PRIMARY KEY (rc_id)
 );
 CREATE INDEX rc_timestamp ON recentchanges (rc_timestamp);
index fffa891..ded573b 100644 (file)
@@ -310,7 +310,9 @@ CREATE TABLE recentchanges (
   rc_moved_to_ns     SMALLINT,
   rc_moved_to_title  TEXT,
   rc_patrolled       CHAR         NOT NULL  DEFAULT '0',
-  rc_ip              CIDR
+  rc_ip              CIDR,
+  rc_old_len         INTEGER                DEFAULT '0',
+  rc_new_len         INTEGER                DEFAULT '0',
 );
 CREATE INDEX rc_timestamp       ON recentchanges (rc_timestamp);
 CREATE INDEX rc_namespace_title ON recentchanges (rc_namespace, rc_title);
index d210179..e2c6737 100644 (file)
@@ -798,6 +798,11 @@ CREATE TABLE /*$wgDBprefix*/recentchanges (
   -- $wgPutIPinRC option is enabled.
   rc_ip char(15) NOT NULL default '',
   
+  -- Text length in characters before
+  -- and after the edit
+  rc_old_len int(10) default '0',
+  rc_new_len int(10) default '0',
+
   PRIMARY KEY rc_id (rc_id),
   INDEX rc_timestamp (rc_timestamp),
   INDEX rc_namespace_title (rc_namespace, rc_title),
index f319cb4..a61748a 100644 (file)
@@ -43,6 +43,8 @@ $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( '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' ),
index 30cd1f8..73a6fee 100644 (file)
@@ -494,4 +494,9 @@ div.gallerytext {
 
 .templatesUsed { margin-top: 1.5em; }
 
-#toolbar { clear: both; }
\ No newline at end of file
+#toolbar { clear: both; }
+
+.mw-plusminus-bold { font-weight: bold; }
+.mw-plusminus-pos { font-weight: normal; }
+.mw-plusminus-null { color: #aaa; }
+.mw-plusminus-neg { font-weight: normal; }
\ No newline at end of file
index ff037ee..42e7ff3 100644 (file)
@@ -1540,4 +1540,9 @@ table.multipageimage td {
 .mw-summary-preview {
        margin: 0.1em 0;
 }
-#toolbar { clear: both; }
\ No newline at end of file
+#toolbar { clear: both; }
+
+.mw-plusminus-bold { font-weight: bold; }
+.mw-plusminus-pos { font-weight: normal; }
+.mw-plusminus-null { color: #aaa; }
+.mw-plusminus-neg { font-weight: normal; }
\ No newline at end of file
index deda8be..0d114ed 100644 (file)
@@ -437,4 +437,9 @@ table.collapsed tr.collapsable {
 }
 
 .templatesUsed { margin-top: 1.5em; }
-#toolbar { clear: both; }
\ No newline at end of file
+#toolbar { clear: both; }
+
+.mw-plusminus-bold { font-weight: bold; }
+.mw-plusminus-pos { font-weight: normal; }
+.mw-plusminus-null { color: #aaa; }
+.mw-plusminus-neg { font-weight: normal; }
\ No newline at end of file