From: Leon Weber Date: Sat, 9 Dec 2006 11:36:35 +0000 (+0000) Subject: * DB schema change: added two columns (rc_old_len and rc_new_len) to the recentchange... X-Git-Tag: 1.31.0-rc.0~54955 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=753133808085f12c4dc346473e2d4223b8bfebb2;p=lhc%2Fweb%2Fwiklou.git * 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 --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 85e66dae45..97d2bfcc91 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 54b7981878..c918de97f6 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -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 .= ' ' . $rc->getCharacterDifference(); + } + $time .= ' '; $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 .= ''; # Article link $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched ); diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 74053b53c0..b295789968 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 */ diff --git a/includes/RecentChange.php b/includes/RecentChange.php index d1cda39d75..781d74c1ea 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -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 "($szdiff)"; + } elseif( $szdiff === 0 ) { + return "($szdiff)"; + } elseif( $szdiff > 0 ) { + return "(+$szdiff)"; + } else { + return "($szdiff)"; + } + } } ?> diff --git a/maintenance/archives/patch-rc_new_len.sql b/maintenance/archives/patch-rc_new_len.sql new file mode 100644 index 0000000000..6cdd48d7d9 --- /dev/null +++ b/maintenance/archives/patch-rc_new_len.sql @@ -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 index 0000000000..8b46ba3169 --- /dev/null +++ b/maintenance/archives/patch-rc_old_len.sql @@ -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; + diff --git a/maintenance/mysql5/tables-binary.sql b/maintenance/mysql5/tables-binary.sql index 0d5dc3fe06..d9caafaf5b 100644 --- a/maintenance/mysql5/tables-binary.sql +++ b/maintenance/mysql5/tables-binary.sql @@ -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), diff --git a/maintenance/mysql5/tables.sql b/maintenance/mysql5/tables.sql index ed8c68465c..cc624bafb0 100644 --- a/maintenance/mysql5/tables.sql +++ b/maintenance/mysql5/tables.sql @@ -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), diff --git a/maintenance/oracle/tables.sql b/maintenance/oracle/tables.sql index 7b24d1ee08..030f427f87 100644 --- a/maintenance/oracle/tables.sql +++ b/maintenance/oracle/tables.sql @@ -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); diff --git a/maintenance/postgres/tables.sql b/maintenance/postgres/tables.sql index fffa8910e5..ded573bea0 100644 --- a/maintenance/postgres/tables.sql +++ b/maintenance/postgres/tables.sql @@ -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); diff --git a/maintenance/tables.sql b/maintenance/tables.sql index d210179657..e2c67373c6 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -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), diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index f319cb4dd9..a61748ad07 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -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' ), diff --git a/skins/chick/main.css b/skins/chick/main.css index 30cd1f84b0..73a6feebda 100644 --- a/skins/chick/main.css +++ b/skins/chick/main.css @@ -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 diff --git a/skins/monobook/main.css b/skins/monobook/main.css index ff037ee255..42e7ff37be 100644 --- a/skins/monobook/main.css +++ b/skins/monobook/main.css @@ -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 diff --git a/skins/simple/main.css b/skins/simple/main.css index deda8be25b..0d114ed7fe 100644 --- a/skins/simple/main.css +++ b/skins/simple/main.css @@ -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