r49152 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49151‎ | r49152 | r49153 >
Date:13:46, 3 April 2009
Author:aaron
Status:ok
Tags:
Comment:
Tweak/fixes to r49149
Modified paths:
  • /trunk/phase3/includes/specials/SpecialRevisiondelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php
@@ -83,14 +83,14 @@
8484 } else if( $this->deleteKey == 'logid' ) {
8585 $this->showLogItems();
8686 }
87 - $qc = $this->getLogQueryCond();
 87+ list($qc,$lim) = $this->getLogQueryCond();
8888 # Show relevant lines from the deletion log
8989 $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" );
90 - LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText(), '', 25, $qc );
 90+ LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText(), '', $lim, $qc );
9191 # Show relevant lines from the suppression log
9292 if( $wgUser->isAllowed( 'suppressionlog' ) ) {
9393 $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" );
94 - LogEventsList::showLogExtract( $wgOut, 'suppress', $this->page->getPrefixedText(), '', 25, $qc );
 94+ LogEventsList::showLogExtract( $wgOut, 'suppress', $this->page->getPrefixedText(), '', $lim, $qc );
9595 }
9696 }
9797
@@ -119,6 +119,7 @@
120120 private function getLogQueryCond() {
121121 $ids = $safeIds = array();
122122 $action = 'revision';
 123+ $limit = 25; // default
123124 switch( $this->deleteKey ) {
124125 case 'oldid':
125126 $ids = $this->oldids;
@@ -140,7 +141,8 @@
141142 // Revision delete logs
142143 $conds = array( 'log_action' => $action );
143144 // Just get the whole log if there are a lot if items
144 - if( count($ids) > 20 ) return $conds;
 145+ if( count($ids) > $limit )
 146+ return array($conds,$limit);
145147 // Digit chars only
146148 foreach( $ids as $id ) {
147149 if( preg_match( '/^\d+$/', $id, $m ) ) {
@@ -149,22 +151,20 @@
150152 }
151153 // Optimization for logs
152154 if( $action == 'event' ) {
153 - # If a context page is given, use title,time index
154 - if( $this->contextPage ) {
155 - $conds['log_namespace'] = $this->contextPage->getNamespace();
156 - $conds['log_title'] = $this->contextPage->getDBKey();
157 - } else {
158 - $first = wfGetDB( DB_SLAVE )->selectField( 'logging',
159 - 'MIN(log_timestamp)', array('log_id' => $safeIds) );
160 - # The event was be hidden after it was made
161 - $conds[] = "log_timestamp >= {$first}"; // use type,time index
162 - }
 155+ $dbr = wfGetDB( DB_SLAVE );
 156+ # Get the timestamp of the first item
 157+ $first = $dbr->selectField( 'logging', 'log_timestamp',
 158+ array('log_id' => $safeIds), __METHOD__, array('ORDER BY' => 'log_id') );
 159+ # If there are no items, then stop here
 160+ if( $first == false ) $conds = '1 = 0';
 161+ # The event was be hidden after it was made
 162+ $conds[] = 'log_timestamp > '.$dbr->addQuotes($first); // type,time index
163163 }
164164 // Format is <id1,id2,i3...>
165165 if( count($safeIds) ) {
166166 $conds[] = "log_params RLIKE '(^|\n|,)(".implode('|',$safeIds).")(,|$)'";
167167 }
168 - return $conds;
 168+ return array($conds,$limit);
169169 }
170170
171171 private function secureOperation() {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r49149RevisionDelete log extract query optimizationsaaron12:58, 3 April 2009

Status & tagging log