r40535 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40534‎ | r40535 | r40536 >
Date:15:01, 6 September 2008
Author:aaron
Status:old
Tags:
Comment:
* Mark non-autoconfirmed users in RC
* Avoid overselecting fields in RC and add $fields to SpecialRecentChangesQuery
* Some whitespace tweaks in RecentChange.php. Remove dead code.
* Avoid rc_new check in ChangesList
* Move some "unpatrolled" CSS to shared.css. Add 'newuser' CSS.
* Bump style version
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/ChangesList.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/RecentChange.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRecentchanges.php (modified) (history)
  • /trunk/phase3/skins/common/oldshared.css (modified) (history)
  • /trunk/phase3/skins/common/shared.css (modified) (history)
  • /trunk/phase3/skins/modern/main.css (modified) (history)
  • /trunk/phase3/skins/monobook/main.css (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/monobook/main.css
@@ -1154,10 +1154,6 @@
11551155 span.newpage, span.minor, span.bot {
11561156 font-weight: bold;
11571157 }
1158 -span.unpatrolled {
1159 - font-weight: bold;
1160 - color: red;
1161 -}
11621158
11631159 .sharedUploadNotice {
11641160 font-style: italic;
Index: trunk/phase3/skins/modern/main.css
@@ -650,10 +650,6 @@
651651 span.newpage, span.minor, span.searchmatch, span.bot {
652652 font-weight: bold;
653653 }
654 -span.unpatrolled {
655 - font-weight: bold;
656 - color: red;
657 -}
658654
659655 span.searchmatch {
660656 color: red;
Index: trunk/phase3/skins/common/oldshared.css
@@ -212,6 +212,10 @@
213213 font-weight:bold;
214214 color:red;
215215 }
 216+span.newuser {
 217+ font-weight:bold;
 218+ color:orange;
 219+}
216220
217221 span.updatedmarker {
218222 color:black;
Index: trunk/phase3/skins/common/shared.css
@@ -56,8 +56,20 @@
5757 }
5858
5959 /*
60 - * rev_deleted stuff
 60+ * Recent changes
6161 */
 62+span.unpatrolled {
 63+ font-weight: bold;
 64+ color: red;
 65+}
 66+span.newuser {
 67+ font-weight:bold;
 68+ color:orange;
 69+}
 70+
 71+/*
 72+ * RevisionDelete stuff
 73+ */
6274 li span.deleted, span.history-deleted {
6375 text-decoration: line-through;
6476 color: #888;
Index: trunk/phase3/docs/hooks.txt
@@ -1218,6 +1218,7 @@
12191219 &$tables: array of tables to be queried
12201220 &$join_conds: join conditions for the tables
12211221 $opts: FormOptions for this request
 1222+&$fields: select fields
12221223
12231224 'SpecialSearchNogomatch': called when user clicked the "Go" button but the target doesn't exist
12241225 $title: title object generated from the text entred by the user
Index: trunk/phase3/includes/RecentChange.php
@@ -49,15 +49,13 @@
5050
5151 # Factory methods
5252
53 - public static function newFromRow( $row )
54 - {
 53+ public static function newFromRow( $row ) {
5554 $rc = new RecentChange;
5655 $rc->loadFromRow( $row );
5756 return $rc;
5857 }
5958
60 - public static function newFromCurRow( $row )
61 - {
 59+ public static function newFromCurRow( $row ) {
6260 $rc = new RecentChange;
6361 $rc->loadFromCurRow( $row );
6462 $rc->notificationtimestamp = false;
@@ -110,26 +108,22 @@
111109
112110 # Accessors
113111
114 - function setAttribs( $attribs )
115 - {
 112+ function setAttribs( $attribs ) {
116113 $this->mAttribs = $attribs;
117114 }
118115
119 - function setExtra( $extra )
120 - {
 116+ function setExtra( $extra ) {
121117 $this->mExtra = $extra;
122118 }
123119
124 - function &getTitle()
125 - {
 120+ function &getTitle() {
126121 if ( $this->mTitle === false ) {
127122 $this->mTitle = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
128123 }
129124 return $this->mTitle;
130125 }
131126
132 - function getMovedToTitle()
133 - {
 127+ function getMovedToTitle() {
134128 if ( $this->mMovedToTitle === false ) {
135129 $this->mMovedToTitle = Title::makeTitle( $this->mAttribs['rc_moved_to_ns'],
136130 $this->mAttribs['rc_moved_to_title'] );
@@ -138,8 +132,7 @@
139133 }
140134
141135 # Writes the data in this object to the database
142 - function save()
143 - {
 136+ function save() {
144137 global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress,
145138 $wgRC2UDPPort, $wgRC2UDPPrefix, $wgRC2UDPOmitBots;
146139 $fname = 'RecentChange::save';
@@ -178,35 +171,6 @@
179172 # Update old rows, if necessary
180173 if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
181174 $lastTime = $this->mExtra['lastTimestamp'];
182 - #$now = $this->mAttribs['rc_timestamp'];
183 - #$curId = $this->mAttribs['rc_cur_id'];
184 -
185 - # Don't bother looking for entries that have probably
186 - # been purged, it just locks up the indexes needlessly.
187 - global $wgRCMaxAge;
188 - $age = time() - wfTimestamp( TS_UNIX, $lastTime );
189 - if( $age < $wgRCMaxAge ) {
190 - # live hack, will commit once tested - kate
191 - # Update rc_this_oldid for the entries which were current
192 - #
193 - #$oldid = $this->mAttribs['rc_last_oldid'];
194 - #$ns = $this->mAttribs['rc_namespace'];
195 - #$title = $this->mAttribs['rc_title'];
196 - #
197 - #$dbw->update( 'recentchanges',
198 - # array( /* SET */
199 - # 'rc_this_oldid' => $oldid
200 - # ), array( /* WHERE */
201 - # 'rc_namespace' => $ns,
202 - # 'rc_title' => $title,
203 - # 'rc_timestamp' => $dbw->timestamp( $lastTime )
204 - # ), $fname
205 - #);
206 - }
207 -
208 - # Update rc_cur_time
209 - #$dbw->update( 'recentchanges', array( 'rc_cur_time' => $now ),
210 - # array( 'rc_cur_id' => $curId ), $fname );
211175 }
212176
213177 # Notify external application via UDP
@@ -576,13 +540,43 @@
577541 public function getAttribute( $name ) {
578542 return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : NULL;
579543 }
 544+
 545+ /*
 546+ * Get RC select fields for changes lists
 547+ */
 548+ public static function getSelectFields() {
 549+ return array(
 550+ 'rc_timestamp',
 551+ 'rc_cur_time',
 552+ 'rc_user',
 553+ 'rc_user_text',
 554+ 'rc_namespace',
 555+ 'rc_title',
 556+ 'rc_comment',
 557+ 'rc_minor',
 558+ 'rc_type',
 559+ 'rc_cur_id',
 560+ 'rc_this_oldid',
 561+ 'rc_last_oldid',
 562+ 'rc_bot',
 563+ 'rc_moved_to_ns',
 564+ 'rc_moved_to_title',
 565+ 'rc_patrolled',
 566+ 'rc_old_len',
 567+ 'rc_new_len',
 568+ 'rc_params',
 569+ 'rc_log_type',
 570+ 'rc_log_action',
 571+ 'rc_log_id',
 572+ 'rc_deleted' // this one REALLY should be set...
 573+ );
 574+ }
580575
581576 /**
582577 * Gets the end part of the diff URL associated with this object
583578 * Blank if no diff link should be displayed
584579 */
585 - function diffLinkTrail( $forceCur )
586 - {
 580+ function diffLinkTrail( $forceCur ) {
587581 if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
588582 $trail = "curid=" . (int)($this->mAttribs['rc_cur_id']) .
589583 "&oldid=" . (int)($this->mAttribs['rc_last_oldid']);
Index: trunk/phase3/includes/ChangesList.php
@@ -75,17 +75,38 @@
7676 * @param bool $patrolled
7777 * @param string $nothing, string to use for empty space
7878 * @param bool $bot
 79+ * @param bool $newbie
7980 * @return string
8081 */
81 - protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = '&nbsp;', $bot = false ) {
 82+ protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = '&nbsp;', $bot = false, $newbie = false ) {
8283 $f = $new ? '<span class="newpage">' . $this->message['newpageletter'] . '</span>'
8384 : $nothing;
8485 $f .= $minor ? '<span class="minor">' . $this->message['minoreditletter'] . '</span>'
8586 : $nothing;
8687 $f .= $bot ? '<span class="bot">' . $this->message['boteditletter'] . '</span>' : $nothing;
8788 $f .= $patrolled ? '<span class="unpatrolled">!</span>' : $nothing;
 89+ $f .= $newbie ? '<span class="newuser">*</span>' : $nothing;
8890 return $f;
8991 }
 92+
 93+ protected static function userIsNew( Array $attribs ) {
 94+ global $wgAutoConfirmCount, $wgAutoConfirmAge;
 95+ if( !array_key_exists('user_editcount',$attribs) || !array_key_exists('user_registration',$attribs) ) {
 96+ return false; // missing input!
 97+ }
 98+ static $time;
 99+ $time = time();
 100+ $edits = $attribs['user_editcount'];
 101+ $age = $attribs['user_registration'];
 102+ if( $wgAutoConfirmCount && !$edits || $wgAutoConfirmAge && !$age ) {
 103+ return true;
 104+ } else if( $wgAutoConfirmCount && $edits < $wgAutoConfirmCount ) {
 105+ return true;
 106+ } else if( $wgAutoConfirmAge && ($time - wfTimestampOrNull(TS_UNIX,$age)) < $wgAutoConfirmAge ) {
 107+ return true;
 108+ }
 109+ return false;
 110+ }
90111
91112 /**
92113 * Returns text for the start of the tabular part of RC
@@ -343,9 +364,10 @@
344365 wfProfileIn($fname.'-page');
345366
346367 $this->insertDiffHist($s, $rc, $unpatrolled);
347 -
348368 # M, N, b and ! (minor, new, bot and unpatrolled)
349 - $s .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $unpatrolled, '', $rc_bot );
 369+ $newbie = self::userIsNew( $rcObj->mAttribs );
 370+ $s .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $unpatrolled, '',
 371+ $rc_bot, $newbie );
350372 $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
351373
352374 wfProfileOut($fname.'-page');
@@ -542,15 +564,14 @@
543565 # Collate list of users
544566 $userlinks = array();
545567 # Other properties
546 - $unpatrolled = false;
547 - $isnew = false;
 568+ $unpatrolled = $isnew = $newbie = false;
548569 $curId = $currentRevision = 0;
549570 # Some catalyst variables...
550571 $namehidden = true;
551572 $alllogs = true;
552573 foreach( $block as $rcObj ) {
553574 $oldid = $rcObj->mAttribs['rc_last_oldid'];
554 - if( $rcObj->mAttribs['rc_new'] ) {
 575+ if( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
555576 $isnew = true;
556577 }
557578 // If all log actions to this page were hidden, then don't
@@ -568,6 +589,9 @@
569590 if( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
570591 $alllogs = false;
571592 }
 593+ if( self::userIsNew( $rcObj->mAttribs ) ) {
 594+ $newbie = true;
 595+ }
572596 # Get the latest entry with a page_id and oldid
573597 # since logs may not have these.
574598 if( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
@@ -606,7 +630,7 @@
607631 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.'&nbsp;';
608632
609633 # Main line
610 - $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, '&nbsp;', $bot );
 634+ $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, '&nbsp;', $bot, $newbie );
611635
612636 # Timestamp
613637 $r .= '&nbsp;'.$block[0]->timestamp.'&nbsp;</tt></td><td>';
@@ -689,7 +713,8 @@
690714 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
691715 $r .= '<tr><td valign="top">';
692716 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
693 - $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled, '&nbsp;', $rc_bot );
 717+ $newbie = self::userIsNew( $rcObj->mAttribs );
 718+ $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled, '&nbsp;', $rc_bot, $newbie );
694719 $r .= '&nbsp;</tt></td><td valign="top">';
695720
696721 $o = '';
@@ -815,14 +840,15 @@
816841 $curIdEq = 'curid='.$rc_cur_id;
817842
818843 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
819 -
820844 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . '&nbsp;';
821845
822846 # Flag and Timestamp
823847 if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
824848 $r .= '&nbsp;&nbsp;&nbsp;&nbsp;'; // 4 flags -> 4 spaces
825849 } else {
826 - $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, '&nbsp;', $rc_bot );
 850+ $newbie = self::userIsNew( $rcObj->mAttribs );
 851+ $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled,
 852+ '&nbsp;', $rc_bot, $newbie );
827853 }
828854 $r .= '&nbsp;'.$rcObj->timestamp.'&nbsp;</tt></td><td>';
829855
@@ -838,7 +864,7 @@
839865 }
840866
841867 # Diff and hist links
842 - if ( $rc_type != RC_LOG ) {
 868+ if( $rc_type != RC_LOG ) {
843869 $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator'];
844870 $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
845871 }
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1383,7 +1383,7 @@
13841384 * to ensure that client-side caches don't keep obsolete copies of global
13851385 * styles.
13861386 */
1387 -$wgStyleVersion = '172';
 1387+$wgStyleVersion = '173';
13881388
13891389
13901390 # Server-side caching:
Index: trunk/phase3/includes/specials/SpecialRecentchanges.php
@@ -264,8 +264,11 @@
265265 public function doMainQuery( $conds, $opts ) {
266266 global $wgUser;
267267
268 - $tables = array( 'recentchanges' );
269 - $join_conds = array();
 268+ $tables = array( 'recentchanges', 'user' );
 269+ $join_conds = array( 'user' => array('LEFT JOIN','rc_user != 0 AND user_id = rc_user') );
 270+ $fields = RecentChange::getSelectFields();
 271+ $fields[] = 'user_editcount';
 272+ $fields[] = 'user_registration';
270273
271274 $uid = $wgUser->getId();
272275 $dbr = wfGetDB( DB_SLAVE );
@@ -276,10 +279,10 @@
277280 // JOIN on watchlist for users
278281 if( $uid ) {
279282 $tables[] = 'watchlist';
280 - $join_conds = array( 'watchlist' => array('LEFT JOIN',"wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace") );
 283+ $join_conds['watchlist'] = array('LEFT JOIN',"wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace");
281284 }
282285
283 - wfRunHooks('SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts ) );
 286+ wfRunHooks('SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts, &$fields ) );
284287
285288 // Is there either one namespace selected or excluded?
286289 // Also, if this is "all" or main namespace, just use timestamp index.
@@ -313,7 +316,7 @@
314317 }
315318
316319 /**
317 - * Send output to $wgOut, only called if not used feeds
 320+ * Send output to $wgOut, only called if not using feeds
318321 *
319322 * @param $rows array of database rows
320323 * @param $opts FormOptions

Follow-up revisions

RevisionCommit summaryAuthorDate
r40901Revert r40627, r40551, r40536, r40535 (mark non-autoconfirmed users in RC and...tstarling05:56, 16 September 2008