From 24b3d9b7884333d90f41d2ba8383af20d4aacffe Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sat, 7 Jul 2012 16:52:39 +0200 Subject: [PATCH] merge two foreach in Special:Contributions This avoids iterate twice through the result set to reach the same Change-Id: I5c27a2bae472999e26ca9da753a999ab706804c6 --- includes/specials/SpecialContributions.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index e8223e8e85..e98e08dff2 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -759,21 +759,15 @@ class ContribsPager extends ReverseChronologicalPager { } function doBatchLookups() { - $this->mResult->rewind(); - $revIds = array(); - foreach ( $this->mResult as $row ) { - if( isset( $row->rev_parent_id ) && $row->rev_parent_id ) { - $revIds[] = $row->rev_parent_id; - } - } - $this->mParentLens = Revision::getParentLengths( $this->getDatabase(), $revIds ); - $this->mResult->rewind(); // reset - # Do a link batch query $this->mResult->seek( 0 ); + $revIds = array(); $batch = new LinkBatch(); # Give some pointers to make (last) links foreach ( $this->mResult as $row ) { + if( isset( $row->rev_parent_id ) && $row->rev_parent_id ) { + $revIds[] = $row->rev_parent_id; + } if ( isset( $row->rev_id ) ) { if ( $this->contribs === 'newbie' ) { // multiple users $batch->add( NS_USER, $row->user_name ); @@ -782,6 +776,7 @@ class ContribsPager extends ReverseChronologicalPager { $batch->add( $row->page_namespace, $row->page_title ); } } + $this->mParentLens = Revision::getParentLengths( $this->getDatabase(), $revIds ); $batch->execute(); $this->mResult->seek( 0 ); } -- 2.20.1