r49742 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49741‎ | r49742 | r49743 >
Date:00:50, 23 April 2009
Author:aaron
Status:reverted (Comments)
Tags:
Comment:
Change for bug 18383, suppress user/talk page on user suppression
Modified paths:
  • /trunk/phase3/includes/specials/SpecialBlockip.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRevisiondelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php
@@ -85,16 +85,15 @@
8686 $this->showImages();
8787 } else if( $this->deleteKey == 'logid' ) {
8888 $this->showLogItems();
89 - return; // no logs for now
9089 }
91 - list($qc,$lim) = $this->getLogQueryCond();
 90+ $qc = $this->getLogQueryCond();
9291 # Show relevant lines from the deletion log
9392 $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
94 - LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText(), '', $lim, $qc );
 93+ LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText(), '', 25, $qc );
9594 # Show relevant lines from the suppression log
9695 if( $wgUser->isAllowed( 'suppressionlog' ) ) {
9796 $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" );
98 - LogEventsList::showLogExtract( $wgOut, 'suppress', $this->page->getPrefixedText(), '', $lim, $qc );
 97+ LogEventsList::showLogExtract( $wgOut, 'suppress', $this->page->getPrefixedText(), '', 25, $qc );
9998 }
10099 }
101100
@@ -121,9 +120,7 @@
122121 }
123122
124123 private function getLogQueryCond() {
125 - $ids = $safeIds = array();
126 - $limit = 25; // default
127 - $conds = array( 'log_action' => 'revision' ); // revision delete logs
 124+ $logAction = 'revision';
128125 switch( $this->deleteKey ) {
129126 case 'oldid':
130127 $ids = $this->oldids;
@@ -137,25 +134,19 @@
138135 case 'fileid':
139136 $ids = $this->fileids;
140137 break;
 138+ case 'logid':
 139+ $ids = $this->logids;
 140+ $logAction = 'event';
 141+ break;
141142 default: // bad type?
142 - return array($conds,$limit);
 143+ return array();
143144 }
144 - // Just get the whole log if there are a lot if items
145 - if( count($ids) > $limit )
146 - return array($conds,$limit);
147 - // Digit chars only
148 - foreach( $ids as $id ) {
149 - if( preg_match( '/^\d+$/', $id, $m ) ) {
150 - $safeIds[] = $m[0];
151 - }
152 - }
153 - // Format is <id1,id2,i3...>
154 - if( count($safeIds) ) {
155 - $conds[] = "log_params RLIKE '^{$this->deleteKey}.*(^|\n|,)(".implode('|',$safeIds).")(,|\n|$)'";
156 - } else {
157 - $conds = array('1=0');
158 - }
159 - return array($conds,$limit);
 145+ // Revision delete logs for these item
 146+ $conds = array( 'log_action' => $logAction );
 147+ $conds['ls_field'] = RevisionDeleter::getRelationType( $this->deleteKey );
 148+ $conds['ls_value'] = $ids;
 149+ $conds[] = 'log_id = ls_log_id';
 150+ return $conds;
160151 }
161152
162153 private function secureOperation() {
@@ -1541,18 +1532,41 @@
15421533 $param, $items = array() )
15431534 {
15441535 // Put things hidden from sysops in the oversight log
1545 - $logtype = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ?
 1536+ $logType = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ?
15461537 'suppress' : 'delete';
1547 - $log = new LogPage( $logtype );
 1538+ // Log deletions show with a difference action message
 1539+ $logAction = ( $param == 'logid' ) ? 'event' : 'revision';
 1540+ // Track what items changed here
15481541 $itemCSV = implode(',',$items);
1549 -
 1542+ // Add params for effected page and ids
15501543 if( $param == 'logid' ) {
15511544 $params = array( $itemCSV, "ofield={$obitfield}", "nfield={$nbitfield}" );
1552 - $log->addEntry( 'event', $title, $comment, $params );
15531545 } else {
1554 - // Add params for effected page and ids
15551546 $params = array( $param, $itemCSV, "ofield={$obitfield}", "nfield={$nbitfield}" );
1556 - $log->addEntry( 'revision', $title, $comment, $params );
15571547 }
 1548+ // Actually add the deletion log entry
 1549+ $log = new LogPage( $logType );
 1550+ $logid = $log->addEntry( $logAction, $title, $comment, $params );
 1551+ // Allow for easy searching of deletion log items for revision/log items
 1552+ $log->addRelations( self::getRelationType($param), $items, $logid );
15581553 }
 1554+
 1555+ // Get DB field name for URL param...
 1556+ // Future code for other things may also track
 1557+ // other types of revision-specific changes.
 1558+ public static function getRelationType( $param ) {
 1559+ switch( $param ) {
 1560+ case 'oldid':
 1561+ return 'rev_id';
 1562+ case 'artimestamp':
 1563+ return 'rev_timestamp';
 1564+ case 'oldimage':
 1565+ return 'oi_timestamp';
 1566+ case 'fileid':
 1567+ return 'file_id';
 1568+ case 'logid':
 1569+ return 'log_id';
 1570+ }
 1571+ throw new MWException( "Bad log URL param type!" );
 1572+ }
15591573 }
Index: trunk/phase3/includes/specials/SpecialBlockip.php
@@ -450,13 +450,12 @@
451451
452452 # Set *_deleted fields if requested
453453 if( $this->BlockHideName ) {
454 - self::suppressUserName( $this->BlockAddress, $userId );
 454+ self::suppressUserName( $this->BlockAddress, $userId, $reasonstr );
455455 }
456456
457 - if( $this->BlockWatchUser &&
458 - # Only show watch link when this is no range block
459 - $block->mRangeStart == $block->mRangeEnd) {
460 - $wgUser->addWatch ( Title::makeTitle( NS_USER, $this->BlockAddress ) );
 457+ # Only show watch link when this is no range block
 458+ if( $this->BlockWatchUser && $block->mRangeStart == $block->mRangeEnd ) {
 459+ $wgUser->addWatch( Title::makeTitle( NS_USER, $this->BlockAddress ) );
461460 }
462461
463462 # Block constructor sanitizes certain block options on insert
@@ -481,7 +480,20 @@
482481 }
483482 }
484483
485 - public static function suppressUserName( $name, $userId ) {
 484+ public static function suppressUserName( $name, $userId, $reason = '' ) {
 485+ $user = User::newFromName( $name, false );
 486+ # Delete the user pages that exists
 487+ $title = $user->getUserPage();
 488+ if( ($id = $title->getArticleID(GAID_FOR_UPDATE)) ) {
 489+ $article = new Article( $title );
 490+ $article->doDeleteArticle( $reason, true /*suppress*/, $id );
 491+ }
 492+ # Delete the user talk pages that exists
 493+ $title = $user->getTalkPage();
 494+ if( $id = $title->getArticleID(GAID_FOR_UPDATE) ) {
 495+ $article = new Article( $title );
 496+ $article->doDeleteArticle( $reason, true /*suppress*/, $id );
 497+ }
486498 $op = '|'; // bitwise OR
487499 return self::setUsernameBitfields( $name, $userId, $op );
488500 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r49743revert code from r49742 accidentally committedaaron00:52, 23 April 2009
r51060reverted r49742 per CR; also it doesn't handle subpages anywayaaron13:46, 27 May 2009

Comments

#Comment by Aaron Schulz (talk | contribs)   00:54, 23 April 2009

SpecialRevisiondelete.php reverted, not meant to be committed

#Comment by Tim Starling (talk | contribs)   08:08, 4 May 2009

Possible revert candidate along the lines of my comments on bug 18678. Not backported to 1.15. I would like to hear Brion's opinion.

#Comment by Tim Starling (talk | contribs)   13:39, 26 May 2009

I will disable the hideuser feature on Wikimedia post-scap, if this is not fixed at that time.

#Comment by Aaron Schulz (talk | contribs)   13:38, 27 May 2009

This commit or the block suppress UI message in general?

#Comment by Tim Starling (talk | contribs)   04:13, 28 May 2009

Reverting this commit should be good enough for now. It's certainly a useful feature, I just think the UI has to be done differently.

Status & tagging log