MediaWiki r18237 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r18236‎ | r18237 (on ViewVC)‎ | r18238 >
Date:11:36, 9 December 2006
Author:leon
Status:old
Tags:
Comment:
* 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
Modified paths:

Diff [purge]

Index: trunk/phase3/maintenance/archives/patch-rc_new_len.sql
===================================================================
--- trunk/phase3/maintenance/archives/patch-rc_new_len.sql	(revision 0)
+++ trunk/phase3/maintenance/archives/patch-rc_new_len.sql	(revision 18237)
@@ -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;
+

Property changes on: trunk/phase3/maintenance/archives/patch-rc_new_len.sql
___________________________________________________________________
Name: svn:eol-style
   + native

Index: trunk/phase3/maintenance/archives/patch-rc_old_len.sql
===================================================================
--- trunk/phase3/maintenance/archives/patch-rc_old_len.sql	(revision 0)
+++ trunk/phase3/maintenance/archives/patch-rc_old_len.sql	(revision 18237)
@@ -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;
+

Property changes on: trunk/phase3/maintenance/archives/patch-rc_old_len.sql
___________________________________________________________________
Name: svn:eol-style
   + native

Index: trunk/phase3/maintenance/postgres/tables.sql
===================================================================
--- trunk/phase3/maintenance/postgres/tables.sql	(revision 18236)
+++ trunk/phase3/maintenance/postgres/tables.sql	(revision 18237)
@@ -310,7 +310,9 @@
   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: trunk/phase3/maintenance/updaters.inc
===================================================================
--- trunk/phase3/maintenance/updaters.inc	(revision 18236)
+++ trunk/phase3/maintenance/updaters.inc	(revision 18237)
@@ -43,6 +43,8 @@
 	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: trunk/phase3/maintenance/oracle/tables.sql
===================================================================
--- trunk/phase3/maintenance/oracle/tables.sql	(revision 18236)
+++ trunk/phase3/maintenance/oracle/tables.sql	(revision 18237)
@@ -229,6 +229,8 @@
 	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: trunk/phase3/maintenance/mysql5/tables.sql
===================================================================
--- trunk/phase3/maintenance/mysql5/tables.sql	(revision 18236)
+++ trunk/phase3/maintenance/mysql5/tables.sql	(revision 18237)
@@ -811,6 +811,11 @@
   -- $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: trunk/phase3/maintenance/mysql5/tables-binary.sql
===================================================================
--- trunk/phase3/maintenance/mysql5/tables-binary.sql	(revision 18236)
+++ trunk/phase3/maintenance/mysql5/tables-binary.sql	(revision 18237)
@@ -820,6 +820,11 @@
   -- $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: trunk/phase3/maintenance/tables.sql
===================================================================
--- trunk/phase3/maintenance/tables.sql	(revision 18236)
+++ trunk/phase3/maintenance/tables.sql	(revision 18237)
@@ -798,6 +798,11 @@
   -- $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: trunk/phase3/skins/chick/main.css
===================================================================
--- trunk/phase3/skins/chick/main.css	(revision 18236)
+++ trunk/phase3/skins/chick/main.css	(revision 18237)
@@ -494,4 +494,9 @@
 
 .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: trunk/phase3/skins/monobook/main.css
===================================================================
--- trunk/phase3/skins/monobook/main.css	(revision 18236)
+++ trunk/phase3/skins/monobook/main.css	(revision 18237)
@@ -1540,4 +1540,9 @@
 .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: trunk/phase3/skins/simple/main.css
===================================================================
--- trunk/phase3/skins/simple/main.css	(revision 18236)
+++ trunk/phase3/skins/simple/main.css	(revision 18237)
@@ -437,4 +437,9 @@
 }
 
 .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: trunk/phase3/includes/RecentChange.php
===================================================================
--- trunk/phase3/includes/RecentChange.php	(revision 18236)
+++ trunk/phase3/includes/RecentChange.php	(revision 18237)
@@ -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 @@
 		$oldId, $lastTimestamp, $bot = "default", $ip = '', $oldSize = 0, $newSize = 0,
 		$newId = 0)
 	{
+
 		if ( $bot === 'default' ) {
 			$bot = $user->isAllowed( 'bot' );
 		}
@@ -240,9 +243,11 @@
 			'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 @@
 		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>";
+		}
+	}
 }
 ?>
Index: trunk/phase3/includes/ChangesList.php
===================================================================
--- trunk/phase3/includes/ChangesList.php	(revision 18236)
+++ trunk/phase3/includes/ChangesList.php	(revision 18237)
@@ -212,8 +212,6 @@
 		global $wgUseRCPatrol, $wgUser;
 		return( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) );
 	}
-
-
 }
 
 
@@ -225,12 +223,11 @@
 	 * 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 @@
 
 			$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 @@
 	 * 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 @@
 		}
 
 		$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 @@
 	 * Enhanced RC group
 	 */
 	function recentChangesBlockGroup( $block ) {
-		global $wgContLang;
+		global $wgContLang, $wgRCShowChangedSize;
 		$r = '';
 
 		# Collate list of users
@@ -456,7 +462,6 @@
 
 		# Timestamp
 		$r .= ' '.$block[0]->timestamp.' ';
-		$r .= '</tt>';
 
 		# Article link
 		$r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 18236)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 18237)
@@ -1048,8 +1048,9 @@
  * to ensure that client-side caches don't keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '32';
+$wgStyleVersion = '33';
 
+
 # Server-side caching:
 
 /**
@@ -1095,12 +1096,21 @@
 $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 */
 $wgShowUpdatedMarker 				= true;
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 18236)
+++ trunk/phase3/RELEASE-NOTES	(revision 18237)
@@ -254,8 +254,12 @@
 * 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 ==
 
 * Bishnupriya Manipuri (bpy)
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox