Index: trunk/phase3/includes/actions/HistoryAction.php |
— | — | @@ -316,6 +316,10 @@ |
317 | 317 | public $lastRow = false, $counter, $historyPage, $buttons, $conds; |
318 | 318 | protected $oldIdChecked; |
319 | 319 | protected $preventClickjacking = false; |
| 320 | + /** |
| 321 | + * @var array |
| 322 | + */ |
| 323 | + protected $parentLens; |
320 | 324 | |
321 | 325 | function __construct( $historyPage, $year = '', $month = '', $tagFilter = '', $conds = array() ) { |
322 | 326 | parent::__construct( $historyPage->getContext() ); |
— | — | @@ -384,7 +388,11 @@ |
385 | 389 | # Do a link batch query |
386 | 390 | $this->mResult->seek( 0 ); |
387 | 391 | $batch = new LinkBatch(); |
| 392 | + $revIds = array(); |
388 | 393 | foreach ( $this->mResult as $row ) { |
| 394 | + if( $row->rev_parent_id ) { |
| 395 | + $revIds[] = $row->rev_parent_id; |
| 396 | + } |
389 | 397 | if( !is_null( $row->user_name ) ) { |
390 | 398 | $batch->add( NS_USER, $row->user_name ); |
391 | 399 | $batch->add( NS_USER_TALK, $row->user_name ); |
— | — | @@ -393,11 +401,35 @@ |
394 | 402 | $batch->add( NS_USER_TALK, $row->rev_user_text ); |
395 | 403 | } |
396 | 404 | } |
| 405 | + $this->parentLens = $this->getParentLengths( $revIds ); |
397 | 406 | $batch->execute(); |
398 | 407 | $this->mResult->seek( 0 ); |
399 | 408 | } |
400 | 409 | |
401 | 410 | /** |
| 411 | + * Do a batched query to get the parent revision lengths |
| 412 | + * @param $revIds array |
| 413 | + * @return array |
| 414 | + * @TODO: stolen from Contributions, refactor |
| 415 | + */ |
| 416 | + private function getParentLengths( array $revIds ) { |
| 417 | + $revLens = array(); |
| 418 | + if ( !$revIds ) { |
| 419 | + return $revLens; // empty |
| 420 | + } |
| 421 | + wfProfileIn( __METHOD__ ); |
| 422 | + $res = $this->mDb->select( 'revision', |
| 423 | + array( 'rev_id', 'rev_len' ), |
| 424 | + array( 'rev_id' => $revIds ), |
| 425 | + __METHOD__ ); |
| 426 | + foreach ( $res as $row ) { |
| 427 | + $revLens[$row->rev_id] = $row->rev_len; |
| 428 | + } |
| 429 | + wfProfileOut( __METHOD__ ); |
| 430 | + return $revLens; |
| 431 | + } |
| 432 | + |
| 433 | + /** |
402 | 434 | * Creates begin of history list with a submit button |
403 | 435 | * |
404 | 436 | * @return string HTML output |
— | — | @@ -574,7 +606,9 @@ |
575 | 607 | } |
576 | 608 | |
577 | 609 | # Size is always public data |
578 | | - $prevSize = $prevRev ? $prevRev->getSize() : 0; |
| 610 | + $prevSize = isset( $this->parentLens[$row->rev_parent_id] ) |
| 611 | + ? $this->parentLens[$row->rev_parent_id] |
| 612 | + : 0; |
579 | 613 | $sDiff = ChangesList::showCharacterDifference( $prevSize, $rev->getSize() ); |
580 | 614 | $fSize = Linker::formatRevisionSize($rev->getSize()); |
581 | 615 | $s .= " . . $fSize $sDiff . . "; |