r40901 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40900‎ | r40901 | r40902 >
Date:05:56, 16 September 2008
Author:tstarling
Status:old
Tags:
Comment:
Revert r40627, r40551, r40536, r40535 (mark non-autoconfirmed users in RC and watchlist with an orange asterisk). Potentially slow, potentially controversial, so it needs a configuration option to enable/disable it.
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/ChangesList.php (modified) (history)
  • /trunk/phase3/includes/RecentChange.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRecentchanges.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialWatchlist.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,6 +1154,10 @@
11551155 span.newpage, span.minor, span.bot {
11561156 font-weight: bold;
11571157 }
 1158+span.unpatrolled {
 1159+ font-weight: bold;
 1160+ color: red;
 1161+}
11581162
11591163 .sharedUploadNotice {
11601164 font-style: italic;
Index: trunk/phase3/skins/modern/main.css
@@ -650,6 +650,10 @@
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+}
654658
655659 span.searchmatch {
656660 color: red;
Index: trunk/phase3/skins/common/oldshared.css
@@ -212,10 +212,6 @@
213213 font-weight:bold;
214214 color:red;
215215 }
216 -span.newuser {
217 - font-weight:bold;
218 - color:orange;
219 -}
220216
221217 span.updatedmarker {
222218 color:black;
Index: trunk/phase3/skins/common/shared.css
@@ -56,20 +56,8 @@
5757 }
5858
5959 /*
60 - * Recent changes
 60+ * rev_deleted stuff
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 - */
7462 li span.deleted, span.history-deleted {
7563 text-decoration: line-through;
7664 color: #888;
Index: trunk/phase3/docs/hooks.txt
@@ -1231,7 +1231,6 @@
12321232 &$tables: array of tables to be queried
12331233 &$join_conds: join conditions for the tables
12341234 $opts: FormOptions for this request
1235 -&$fields: select fields
12361235
12371236 'SpecialSearchNogomatch': called when user clicked the "Go" button but the target doesn't exist
12381237 $title: title object generated from the text entred by the user
Index: trunk/phase3/includes/RecentChange.php
@@ -49,13 +49,15 @@
5050
5151 # Factory methods
5252
53 - public static function newFromRow( $row ) {
 53+ public static function newFromRow( $row )
 54+ {
5455 $rc = new RecentChange;
5556 $rc->loadFromRow( $row );
5657 return $rc;
5758 }
5859
59 - public static function newFromCurRow( $row ) {
 60+ public static function newFromCurRow( $row )
 61+ {
6062 $rc = new RecentChange;
6163 $rc->loadFromCurRow( $row );
6264 $rc->notificationtimestamp = false;
@@ -108,22 +110,26 @@
109111
110112 # Accessors
111113
112 - function setAttribs( $attribs ) {
 114+ function setAttribs( $attribs )
 115+ {
113116 $this->mAttribs = $attribs;
114117 }
115118
116 - function setExtra( $extra ) {
 119+ function setExtra( $extra )
 120+ {
117121 $this->mExtra = $extra;
118122 }
119123
120 - function &getTitle() {
 124+ function &getTitle()
 125+ {
121126 if ( $this->mTitle === false ) {
122127 $this->mTitle = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
123128 }
124129 return $this->mTitle;
125130 }
126131
127 - function getMovedToTitle() {
 132+ function getMovedToTitle()
 133+ {
128134 if ( $this->mMovedToTitle === false ) {
129135 $this->mMovedToTitle = Title::makeTitle( $this->mAttribs['rc_moved_to_ns'],
130136 $this->mAttribs['rc_moved_to_title'] );
@@ -132,7 +138,8 @@
133139 }
134140
135141 # Writes the data in this object to the database
136 - function save() {
 142+ function save()
 143+ {
137144 global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress,
138145 $wgRC2UDPPort, $wgRC2UDPPrefix, $wgRC2UDPOmitBots;
139146 $fname = 'RecentChange::save';
@@ -171,6 +178,35 @@
172179 # Update old rows, if necessary
173180 if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
174181 $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 );
175211 }
176212
177213 # Notify external application via UDP
@@ -540,43 +576,13 @@
541577 public function getAttribute( $name ) {
542578 return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : NULL;
543579 }
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 - }
575580
576581 /**
577582 * Gets the end part of the diff URL associated with this object
578583 * Blank if no diff link should be displayed
579584 */
580 - function diffLinkTrail( $forceCur ) {
 585+ function diffLinkTrail( $forceCur )
 586+ {
581587 if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
582588 $trail = "curid=" . (int)($this->mAttribs['rc_cur_id']) .
583589 "&oldid=" . (int)($this->mAttribs['rc_last_oldid']);
Index: trunk/phase3/includes/ChangesList.php
@@ -75,38 +75,17 @@
7676 * @param bool $patrolled
7777 * @param string $nothing, string to use for empty space
7878 * @param bool $bot
79 - * @param bool $newbie
8079 * @return string
8180 */
82 - protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = '&nbsp;', $bot = false, $newbie = false ) {
 81+ protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = '&nbsp;', $bot = false ) {
8382 $f = $new ? '<span class="newpage">' . $this->message['newpageletter'] . '</span>'
8483 : $nothing;
8584 $f .= $minor ? '<span class="minor">' . $this->message['minoreditletter'] . '</span>'
8685 : $nothing;
8786 $f .= $bot ? '<span class="bot">' . $this->message['boteditletter'] . '</span>' : $nothing;
8887 $f .= $patrolled ? '<span class="unpatrolled">!</span>' : $nothing;
89 - $f .= $newbie ? '<span class="newuser">*</span>' : $nothing;
9088 return $f;
9189 }
92 -
93 - protected static function userIsNew( $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 - }
11190
11291 /**
11392 * Returns text for the start of the tabular part of RC
@@ -364,10 +343,9 @@
365344 wfProfileIn($fname.'-page');
366345
367346 $this->insertDiffHist($s, $rc, $unpatrolled);
 347+
368348 # M, N, b and ! (minor, new, bot and unpatrolled)
369 - $newbie = self::userIsNew( $rc->mAttribs );
370 - $s .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $unpatrolled, '',
371 - $rc_bot, $newbie );
 349+ $s .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $unpatrolled, '', $rc_bot );
372350 $this->insertArticleLink($s, $rc, $unpatrolled, $watched);
373351
374352 wfProfileOut($fname.'-page');
@@ -564,14 +542,15 @@
565543 # Collate list of users
566544 $userlinks = array();
567545 # Other properties
568 - $unpatrolled = $isnew = $newbie = false;
 546+ $unpatrolled = false;
 547+ $isnew = false;
569548 $curId = $currentRevision = 0;
570549 # Some catalyst variables...
571550 $namehidden = true;
572551 $alllogs = true;
573552 foreach( $block as $rcObj ) {
574553 $oldid = $rcObj->mAttribs['rc_last_oldid'];
575 - if( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
 554+ if( $rcObj->mAttribs['rc_new'] ) {
576555 $isnew = true;
577556 }
578557 // If all log actions to this page were hidden, then don't
@@ -589,9 +568,6 @@
590569 if( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
591570 $alllogs = false;
592571 }
593 - if( self::userIsNew( $rcObj->mAttribs ) ) {
594 - $newbie = true;
595 - }
596572 # Get the latest entry with a page_id and oldid
597573 # since logs may not have these.
598574 if( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
@@ -630,7 +606,7 @@
631607 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.'&nbsp;';
632608
633609 # Main line
634 - $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, '&nbsp;', $bot, $newbie );
 610+ $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, '&nbsp;', $bot );
635611
636612 # Timestamp
637613 $r .= '&nbsp;'.$block[0]->timestamp.'&nbsp;</tt></td><td>';
@@ -713,8 +689,7 @@
714690 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
715691 $r .= '<tr><td valign="top">';
716692 $r .= '<tt>'.$this->spacerIndent() . $this->spacerIndent();
717 - $newbie = self::userIsNew( $rcObj->mAttribs );
718 - $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled, '&nbsp;', $rc_bot, $newbie );
 693+ $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled, '&nbsp;', $rc_bot );
719694 $r .= '&nbsp;</tt></td><td valign="top">';
720695
721696 $o = '';
@@ -840,15 +815,14 @@
841816 $curIdEq = 'curid='.$rc_cur_id;
842817
843818 $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>';
 819+
844820 $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . '&nbsp;';
845821
846822 # Flag and Timestamp
847823 if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
848824 $r .= '&nbsp;&nbsp;&nbsp;&nbsp;'; // 4 flags -> 4 spaces
849825 } else {
850 - $newbie = self::userIsNew( $rcObj->mAttribs );
851 - $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled,
852 - '&nbsp;', $rc_bot, $newbie );
 826+ $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, '&nbsp;', $rc_bot );
853827 }
854828 $r .= '&nbsp;'.$rcObj->timestamp.'&nbsp;</tt></td><td>';
855829
@@ -864,7 +838,7 @@
865839 }
866840
867841 # Diff and hist links
868 - if( $rc_type != RC_LOG ) {
 842+ if ( $rc_type != RC_LOG ) {
869843 $r .= ' ('. $rcObj->difflink . $this->message['semicolon-separator'];
870844 $r .= $this->skin->makeKnownLinkObj( $rcObj->getTitle(), wfMsg( 'hist' ), $curIdEq.'&action=history' ) . ')';
871845 }
Index: trunk/phase3/includes/specials/SpecialRecentchanges.php
@@ -264,11 +264,8 @@
265265 public function doMainQuery( $conds, $opts ) {
266266 global $wgUser;
267267
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';
 268+ $tables = array( 'recentchanges' );
 269+ $join_conds = array();
273270
274271 $uid = $wgUser->getId();
275272 $dbr = wfGetDB( DB_SLAVE );
@@ -279,10 +276,10 @@
280277 // JOIN on watchlist for users
281278 if( $uid ) {
282279 $tables[] = 'watchlist';
283 - $join_conds['watchlist'] = array('LEFT JOIN',"wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace");
 280+ $join_conds = array( 'watchlist' => array('LEFT JOIN',"wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace") );
284281 }
285282
286 - wfRunHooks('SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts, &$fields ) );
 283+ wfRunHooks('SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts ) );
287284
288285 // Is there either one namespace selected or excluded?
289286 // Also, if this is "all" or main namespace, just use timestamp index.
@@ -316,7 +313,7 @@
317314 }
318315
319316 /**
320 - * Send output to $wgOut, only called if not using feeds
 317+ * Send output to $wgOut, only called if not used feeds
321318 *
322319 * @param $rows array of database rows
323320 * @param $opts FormOptions
Index: trunk/phase3/includes/specials/SpecialWatchlist.php
@@ -91,7 +91,7 @@
9292 }
9393
9494 $dbr = wfGetDB( DB_SLAVE, 'watchlist' );
95 - list($page,$watchlist,$recentchanges,$user) = $dbr->tableNamesN('page','watchlist','recentchanges','user');
 95+ list( $page, $watchlist, $recentchanges ) = $dbr->tableNamesN( 'page', 'watchlist', 'recentchanges' );
9696
9797 $watchlistCount = $dbr->selectField( 'watchlist', 'COUNT(*)',
9898 array( 'wl_user' => $uid ), __METHOD__ );
@@ -198,10 +198,9 @@
199199 } else {
200200 $wltsfield = '';
201201 }
202 - $sql = "SELECT ${recentchanges}.* ${wltsfield}, {$user}.user_editcount, {$user}.user_registration
 202+ $sql = "SELECT ${recentchanges}.* ${wltsfield}
203203 FROM $watchlist,$recentchanges
204204 LEFT JOIN $page ON rc_cur_id=page_id
205 - LEFT JOIN $user ON (rc_user !='0' AND rc_user = user_id)
206205 WHERE wl_user=$uid
207206 AND wl_namespace=rc_namespace
208207 AND wl_title=rc_title

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r40535* Mark non-autoconfirmed users in RC...aaron15:01, 6 September 2008
r40536Fix typo for OldChangesListaaron15:11, 6 September 2008
r40551Remove type check for userIsNew(), shouldn't be neededaaron21:52, 6 September 2008
r40627Also mark new user edits here tooaaron23:33, 8 September 2008