From d342f7ad0d5b7ab0e6a201c3843492f79ae16929 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 23 Apr 2009 00:52:35 +0000 Subject: [PATCH] revert code from r49742 accidentally committed --- includes/specials/SpecialRevisiondelete.php | 76 +++++++++------------ 1 file changed, 31 insertions(+), 45 deletions(-) diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index 27cf858932..5857bb8e10 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -85,15 +85,16 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $this->showImages(); } else if( $this->deleteKey == 'logid' ) { $this->showLogItems(); + return; // no logs for now } - $qc = $this->getLogQueryCond(); + list($qc,$lim) = $this->getLogQueryCond(); # Show relevant lines from the deletion log $wgOut->addHTML( "

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

\n" ); - LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText(), '', 25, $qc ); + LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText(), '', $lim, $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(), '', 25, $qc ); + LogEventsList::showLogExtract( $wgOut, 'suppress', $this->page->getPrefixedText(), '', $lim, $qc ); } } @@ -120,7 +121,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { } private function getLogQueryCond() { - $logAction = 'revision'; + $ids = $safeIds = array(); + $limit = 25; // default + $conds = array( 'log_action' => 'revision' ); // revision delete logs switch( $this->deleteKey ) { case 'oldid': $ids = $this->oldids; @@ -134,19 +137,25 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { case 'fileid': $ids = $this->fileids; break; - case 'logid': - $ids = $this->logids; - $logAction = 'event'; - break; default: // bad type? - 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; + 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); } private function secureOperation() { @@ -1532,41 +1541,18 @@ 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 deletions show with a difference action message - $logAction = ( $param == 'logid' ) ? 'event' : 'revision'; - // Track what items changed here + $log = new LogPage( $logtype ); $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