From 56151e659f9e494cdaff34c61ca5147c230874da Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 23 Apr 2009 00:50:54 +0000 Subject: [PATCH] Change for bug 18383, suppress user/talk page on user suppression --- includes/specials/SpecialBlockip.php | 24 +++++-- includes/specials/SpecialRevisiondelete.php | 76 ++++++++++++--------- 2 files changed, 63 insertions(+), 37 deletions(-) diff --git a/includes/specials/SpecialBlockip.php b/includes/specials/SpecialBlockip.php index e33ea83595..80b080566d 100644 --- a/includes/specials/SpecialBlockip.php +++ b/includes/specials/SpecialBlockip.php @@ -450,13 +450,12 @@ class IPBlockForm { # Set *_deleted fields if requested if( $this->BlockHideName ) { - self::suppressUserName( $this->BlockAddress, $userId ); + self::suppressUserName( $this->BlockAddress, $userId, $reasonstr ); } - if( $this->BlockWatchUser && - # Only show watch link when this is no range block - $block->mRangeStart == $block->mRangeEnd) { - $wgUser->addWatch ( Title::makeTitle( NS_USER, $this->BlockAddress ) ); + # Only show watch link when this is no range block + if( $this->BlockWatchUser && $block->mRangeStart == $block->mRangeEnd ) { + $wgUser->addWatch( Title::makeTitle( NS_USER, $this->BlockAddress ) ); } # Block constructor sanitizes certain block options on insert @@ -481,7 +480,20 @@ class IPBlockForm { } } - public static function suppressUserName( $name, $userId ) { + public static function suppressUserName( $name, $userId, $reason = '' ) { + $user = User::newFromName( $name, false ); + # Delete the user pages that exists + $title = $user->getUserPage(); + if( ($id = $title->getArticleID(GAID_FOR_UPDATE)) ) { + $article = new Article( $title ); + $article->doDeleteArticle( $reason, true /*suppress*/, $id ); + } + # Delete the user talk pages that exists + $title = $user->getTalkPage(); + if( $id = $title->getArticleID(GAID_FOR_UPDATE) ) { + $article = new Article( $title ); + $article->doDeleteArticle( $reason, true /*suppress*/, $id ); + } $op = '|'; // bitwise OR return self::setUsernameBitfields( $name, $userId, $op ); } diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index 5857bb8e10..27cf858932 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -85,16 +85,15 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $this->showImages(); } else if( $this->deleteKey == 'logid' ) { $this->showLogItems(); - return; // no logs for now } - list($qc,$lim) = $this->getLogQueryCond(); + $qc = $this->getLogQueryCond(); # Show relevant lines from the deletion log $wgOut->addHTML( "

" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "

\n" ); - LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText(), '', $lim, $qc ); + LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText(), '', 25, $qc ); # Show relevant lines from the suppression log if( $wgUser->isAllowed( 'suppressionlog' ) ) { $wgOut->addHTML( "

" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "

\n" ); - LogEventsList::showLogExtract( $wgOut, 'suppress', $this->page->getPrefixedText(), '', $lim, $qc ); + LogEventsList::showLogExtract( $wgOut, 'suppress', $this->page->getPrefixedText(), '', 25, $qc ); } } @@ -121,9 +120,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { } private function getLogQueryCond() { - $ids = $safeIds = array(); - $limit = 25; // default - $conds = array( 'log_action' => 'revision' ); // revision delete logs + $logAction = 'revision'; switch( $this->deleteKey ) { case 'oldid': $ids = $this->oldids; @@ -137,25 +134,19 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { case 'fileid': $ids = $this->fileids; break; + case 'logid': + $ids = $this->logids; + $logAction = 'event'; + break; default: // bad type? - return array($conds,$limit); - } - // Just get the whole log if there are a lot if items - if( count($ids) > $limit ) - return array($conds,$limit); - // Digit chars only - foreach( $ids as $id ) { - if( preg_match( '/^\d+$/', $id, $m ) ) { - $safeIds[] = $m[0]; - } - } - // Format is - if( count($safeIds) ) { - $conds[] = "log_params RLIKE '^{$this->deleteKey}.*(^|\n|,)(".implode('|',$safeIds).")(,|\n|$)'"; - } else { - $conds = array('1=0'); - } - return array($conds,$limit); + return array(); + } + // Revision delete logs for these item + $conds = array( 'log_action' => $logAction ); + $conds['ls_field'] = RevisionDeleter::getRelationType( $this->deleteKey ); + $conds['ls_value'] = $ids; + $conds[] = 'log_id = ls_log_id'; + return $conds; } private function secureOperation() { @@ -1541,18 +1532,41 @@ class RevisionDeleter { $param, $items = array() ) { // Put things hidden from sysops in the oversight log - $logtype = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ? + $logType = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ? 'suppress' : 'delete'; - $log = new LogPage( $logtype ); + // Log deletions show with a difference action message + $logAction = ( $param == 'logid' ) ? 'event' : 'revision'; + // Track what items changed here $itemCSV = implode(',',$items); - + // Add params for effected page and ids if( $param == 'logid' ) { $params = array( $itemCSV, "ofield={$obitfield}", "nfield={$nbitfield}" ); - $log->addEntry( 'event', $title, $comment, $params ); } else { - // Add params for effected page and ids $params = array( $param, $itemCSV, "ofield={$obitfield}", "nfield={$nbitfield}" ); - $log->addEntry( 'revision', $title, $comment, $params ); } + // Actually add the deletion log entry + $log = new LogPage( $logType ); + $logid = $log->addEntry( $logAction, $title, $comment, $params ); + // Allow for easy searching of deletion log items for revision/log items + $log->addRelations( self::getRelationType($param), $items, $logid ); + } + + // Get DB field name for URL param... + // Future code for other things may also track + // other types of revision-specific changes. + public static function getRelationType( $param ) { + switch( $param ) { + case 'oldid': + return 'rev_id'; + case 'artimestamp': + return 'rev_timestamp'; + case 'oldimage': + return 'oi_timestamp'; + case 'fileid': + return 'file_id'; + case 'logid': + return 'log_id'; + } + throw new MWException( "Bad log URL param type!" ); } } -- 2.20.1