merge two foreach in Special:Contributions
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 7 Jul 2012 14:52:39 +0000 (16:52 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Sat, 7 Jul 2012 14:52:39 +0000 (16:52 +0200)
This avoids iterate twice through the result set to reach the same

Change-Id: I5c27a2bae472999e26ca9da753a999ab706804c6

includes/specials/SpecialContributions.php

index e8223e8..e98e08d 100644 (file)
@@ -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 );
        }