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
@@ -0,0 +1,9 @@
 2+--
 3+-- patch-rc_new_len.sql
 4+-- Adds a row to recentchanges to hold the text size after the edit
 5+-- 2006-12-03
 6+--
 7+
 8+ALTER TABLE /*$wgDBprefix*/recentchanges
 9+ ADD COLUMN rc_new_len int(10) default 0;
 10+
Property changes on: trunk/phase3/maintenance/archives/patch-rc_new_len.sql
___________________________________________________________________
Added: svn:eol-style
111 + native
Index: trunk/phase3/maintenance/archives/patch-rc_old_len.sql
@@ -0,0 +1,9 @@
 2+--
 3+-- patch-rc_old_len.sql
 4+-- Adds a row to recentchanges to hold the text size before the edit
 5+-- 2006-12-03
 6+--
 7+
 8+ALTER TABLE /*$wgDBprefix*/recentchanges
 9+ ADD COLUMN rc_old_len int(10) default 0;
 10+
Property changes on: trunk/phase3/maintenance/archives/patch-rc_old_len.sql
___________________________________________________________________
Added: svn:eol-style
111 + native
Index: trunk/phase3/maintenance/postgres/tables.sql
@@ -310,7 +310,9 @@
311311 rc_moved_to_ns SMALLINT,
312312 rc_moved_to_title TEXT,
313313 rc_patrolled CHAR NOT NULL DEFAULT '0',
314 - rc_ip CIDR
 314+ rc_ip CIDR,
 315+ rc_old_len INTEGER DEFAULT '0',
 316+ rc_new_len INTEGER DEFAULT '0',
315317 );
316318 CREATE INDEX rc_timestamp ON recentchanges (rc_timestamp);
317319 CREATE INDEX rc_namespace_title ON recentchanges (rc_namespace, rc_title);
Index: trunk/phase3/maintenance/updaters.inc
@@ -43,6 +43,8 @@
4444 array( 'recentchanges', 'rc_ip', 'patch-rc_ip.sql' ),
4545 array( 'recentchanges', 'rc_id', 'patch-rc_id.sql' ),
4646 array( 'recentchanges', 'rc_patrolled', 'patch-rc-patrol.sql' ),
 47+ array( 'recentchanges', 'rc_old_len', 'patch-rc_old_len.sql' ),
 48+ array( 'recentchanges', 'rc_new_len', 'patch-rc_new_len.sql' ),
4749 array( 'user', 'user_real_name', 'patch-user-realname.sql' ),
4850 array( 'user', 'user_token', 'patch-user_token.sql' ),
4951 array( 'user', 'user_email_token', 'patch-user_email_token.sql' ),
Index: trunk/phase3/maintenance/oracle/tables.sql
@@ -229,6 +229,8 @@
230230 rc_moved_to_title VARCHAR2(255),
231231 rc_patrolled NUMBER(3) DEFAULT 0 NOT NULL,
232232 rc_ip VARCHAR2(40),
 233+ rc_old_len NUMBER(10) DEFAULT 0,
 234+ rc_new_len NUMBER(10) DEFAULT 0,
233235 CONSTRAINT rc_pk PRIMARY KEY (rc_id)
234236 );
235237 CREATE INDEX rc_timestamp ON recentchanges (rc_timestamp);
Index: trunk/phase3/maintenance/mysql5/tables.sql
@@ -811,6 +811,11 @@
812812 -- $wgPutIPinRC option is enabled.
813813 rc_ip char(15) NOT NULL default '',
814814
 815+ -- Text length in characters before
 816+ -- and after the edit
 817+ rc_old_len int(10) default '0',
 818+ rc_new_len int(10) default '0',
 819+
815820 PRIMARY KEY rc_id (rc_id),
816821 INDEX rc_timestamp (rc_timestamp),
817822 INDEX rc_namespace_title (rc_namespace, rc_title),
Index: trunk/phase3/maintenance/mysql5/tables-binary.sql
@@ -820,6 +820,11 @@
821821 -- $wgPutIPinRC option is enabled.
822822 rc_ip char(15) NOT NULL default '',
823823
 824+ -- Text length in characters before
 825+ -- and after the edit
 826+ rc_old_len int(10) default '0',
 827+ rc_new_len int(10) default '0',
 828+
824829 PRIMARY KEY rc_id (rc_id),
825830 INDEX rc_timestamp (rc_timestamp),
826831 INDEX rc_namespace_title (rc_namespace, rc_title),
Index: trunk/phase3/maintenance/tables.sql
@@ -798,6 +798,11 @@
799799 -- $wgPutIPinRC option is enabled.
800800 rc_ip char(15) NOT NULL default '',
801801
 802+ -- Text length in characters before
 803+ -- and after the edit
 804+ rc_old_len int(10) default '0',
 805+ rc_new_len int(10) default '0',
 806+
802807 PRIMARY KEY rc_id (rc_id),
803808 INDEX rc_timestamp (rc_timestamp),
804809 INDEX rc_namespace_title (rc_namespace, rc_title),
Index: trunk/phase3/skins/chick/main.css
@@ -494,4 +494,9 @@
495495
496496 .templatesUsed { margin-top: 1.5em; }
497497
498 -#toolbar { clear: both; }
\ No newline at end of file
 498+#toolbar { clear: both; }
 499+
 500+.mw-plusminus-bold { font-weight: bold; }
 501+.mw-plusminus-pos { font-weight: normal; }
 502+.mw-plusminus-null { color: #aaa; }
 503+.mw-plusminus-neg { font-weight: normal; }
\ No newline at end of file
Index: trunk/phase3/skins/monobook/main.css
@@ -1540,4 +1540,9 @@
15411541 .mw-summary-preview {
15421542 margin: 0.1em 0;
15431543 }
1544 -#toolbar { clear: both; }
\ No newline at end of file
 1544+#toolbar { clear: both; }
 1545+
 1546+.mw-plusminus-bold { font-weight: bold; }
 1547+.mw-plusminus-pos { font-weight: normal; }
 1548+.mw-plusminus-null { color: #aaa; }
 1549+.mw-plusminus-neg { font-weight: normal; }
\ No newline at end of file
Index: trunk/phase3/skins/simple/main.css
@@ -437,4 +437,9 @@
438438 }
439439
440440 .templatesUsed { margin-top: 1.5em; }
441 -#toolbar { clear: both; }
\ No newline at end of file
 441+#toolbar { clear: both; }
 442+
 443+.mw-plusminus-bold { font-weight: bold; }
 444+.mw-plusminus-pos { font-weight: normal; }
 445+.mw-plusminus-null { color: #aaa; }
 446+.mw-plusminus-neg { font-weight: normal; }
\ No newline at end of file
Index: trunk/phase3/includes/RecentChange.php
@@ -24,6 +24,8 @@
2525 * rc_ip IP address of the user in dotted quad notation
2626 * rc_new obsolete, use rc_type==RC_NEW
2727 * rc_patrolled boolean whether or not someone has marked this edit as patrolled
 28+ * rc_old_len integer character count of the text before the edit
 29+ * rc_new_len the same after the edit
2830 *
2931 * mExtra:
3032 * prefixedDBkey prefixed db key, used by external app via msg queue
@@ -212,6 +214,7 @@
213215 $oldId, $lastTimestamp, $bot = "default", $ip = '', $oldSize = 0, $newSize = 0,
214216 $newId = 0)
215217 {
 218+
216219 if ( $bot === 'default' ) {
217220 $bot = $user->isAllowed( 'bot' );
218221 }
@@ -240,9 +243,11 @@
241244 'rc_bot' => $bot ? 1 : 0,
242245 'rc_moved_to_ns' => 0,
243246 'rc_moved_to_title' => '',
244 - 'rc_ip' => $ip,
245 - 'rc_patrolled' => 0,
246 - 'rc_new' => 0 # obsolete
 247+ 'rc_ip' => $ip,
 248+ 'rc_patrolled' => 0,
 249+ 'rc_new' => 0, # obsolete
 250+ 'rc_old_len' => $oldSize,
 251+ 'rc_new_len' => $newSize
247252 );
248253
249254 $rc->mExtra = array(
@@ -522,5 +527,19 @@
523528 return $fullString;
524529 }
525530
 531+ function getCharacterDifference() {
 532+ global $wgRCChangedSizeThreshold;
 533+ $szdiff = $this->mAttribs['rc_new_len'] - $this->mAttribs['rc_old_len'];
 534+
 535+ if( $szdiff < $wgRCChangedSizeThreshold ) {
 536+ return "<span class='mw-plusminus-big'>($szdiff)</span>";
 537+ } elseif( $szdiff === 0 ) {
 538+ return "<span class='mw-plusminus-null'>($szdiff)</span>";
 539+ } elseif( $szdiff > 0 ) {
 540+ return "<span class='mw-plusminus-pos'>(+$szdiff)</span>";
 541+ } else {
 542+ return "<span class='mw-pluminus-neg'>($szdiff)</span>";
 543+ }
 544+ }
526545 }
527546 ?>
Index: trunk/phase3/includes/ChangesList.php
@@ -212,8 +212,6 @@
213213 global $wgUseRCPatrol, $wgUser;
214214 return( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) );
215215 }
216 -
217 -
218216 }
219217
220218
@@ -225,12 +223,11 @@
226224 * Format a line using the old system (aka without any javascript).
227225 */
228226 function recentChangesLine( &$rc, $watched = false ) {
229 - global $wgContLang;
 227+ global $wgContLang, $wgRCShowChangedSize;
230228
231229 $fname = 'ChangesList::recentChangesLineOld';
232230 wfProfileIn( $fname );
233231
234 -
235232 # Extract DB fields into local scope
236233 extract( $rc->mAttribs );
237234
@@ -258,6 +255,10 @@
259256
260257 $this->insertDiffHist($s, $rc, $unpatrolled);
261258
 259+ if( $wgRCShowChangedSize ) {
 260+ $s .= $rc->getCharacterDifference() . ' . . ';
 261+ }
 262+
262263 # M, N, b and ! (minor, new, bot and unpatrolled)
263264 $s .= ' ' . $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $unpatrolled, '', $rc_bot );
264265 $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
@@ -293,7 +294,7 @@
294295 * Format a line for enhanced recentchange (aka with javascript and block of lines).
295296 */
296297 function recentChangesLine( &$baseRC, $watched = false ) {
297 - global $wgLang, $wgContLang;
 298+ global $wgLang, $wgContLang, $wgRCShowChangedSize;
298299
299300 # Create a specialised object
300301 $rc = RCCacheEntry::newFromParent( $baseRC );
@@ -343,6 +344,11 @@
344345 }
345346
346347 $time = $wgContLang->time( $rc_timestamp, true, true );
 348+ # Character diff
 349+ if( $wgRCShowChangedSize ) {
 350+ $time .= '&nbsp;' . $rc->getCharacterDifference();
 351+ }
 352+ $time .= '</tt> ';
347353 $rc->watched = $watched;
348354 $rc->link = $clink;
349355 $rc->timestamp = $time;
@@ -403,7 +409,7 @@
404410 * Enhanced RC group
405411 */
406412 function recentChangesBlockGroup( $block ) {
407 - global $wgContLang;
 413+ global $wgContLang, $wgRCShowChangedSize;
408414 $r = '';
409415
410416 # Collate list of users
@@ -456,7 +462,6 @@
457463
458464 # Timestamp
459465 $r .= ' '.$block[0]->timestamp.' ';
460 - $r .= '</tt>';
461466
462467 # Article link
463468 $r .= $this->maybeWatchedLink( $block[0]->link, $block[0]->watched );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1048,8 +1048,9 @@
10491049 * to ensure that client-side caches don't keep obsolete copies of global
10501050 * styles.
10511051 */
1052 -$wgStyleVersion = '32';
 1052+$wgStyleVersion = '33';
10531053
 1054+
10541055 # Server-side caching:
10551056
10561057 /**
@@ -1095,12 +1096,21 @@
10961097 $wgEnotifMinorEdits = true; # UPO; false: "minor edits" on pages do not trigger notification mails.
10971098 # # Attention: _every_ change on a user_talk page trigger a notification mail (if the user is not yet notified)
10981099
1099 -
11001100 /** Show watching users in recent changes, watchlist and page history views */
11011101 $wgRCShowWatchingUsers = false; # UPO
11021102 /** Show watching users in Page views */
11031103 $wgPageShowWatchingUsers = false;
 1104+/** Show the amount of changed characters in recent changes */
 1105+$wgRCShowChangedSize = true;
 1106+
11041107 /**
 1108+ * If the difference between the character counts of the text
 1109+ * before and after the edit is below that value, the value will be
 1110+ * highlighted on the RC page.
 1111+ */
 1112+$wgRCChangedSizeThreshold = -500;
 1113+
 1114+/**
11051115 * Show "Updated (since my last visit)" marker in RC view, watchlist and history
11061116 * view for watched pages with new changes */
11071117 $wgShowUpdatedMarker = true;
Index: trunk/phase3/RELEASE-NOTES
@@ -254,8 +254,12 @@
255255 * Added a configuration variable allowing the "break out of framesets" feature
256256 to be switched on and off ($wgBreakFrames). Off by default.
257257 * Allow Xml::check() $attribs parameter to override 'value' attribute
 258+* DB schema change: added two columns (rc_old_len and rc_new_len) to the recentchanges table to store
 259+ the text lengths before and after the edit
 260+* (bug 1085) Made Special:Recentchanges show the character difference between the changed revisions
258261
259262
 263+
260264 == Languages updated ==
261265
262266 * Bishnupriya Manipuri (bpy)