Add LinkBatch to ImagePage for user pages in the file history
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 19 Jun 2015 19:39:50 +0000 (21:39 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Fri, 19 Jun 2015 19:53:02 +0000 (21:53 +0200)
Each user in the file history trigger an own query to get the state of
the user page, talk page and gender information. Use a LinkBatch to
combine all of these queries to two (one for pages, one for gender).

Change-Id: Ic1973c1ccfa17002b343d8c0d110a7c1d20b0460

includes/page/ImagePage.php

index cebc4c4..7ea4ed7 100644 (file)
@@ -1515,6 +1515,18 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
                $s = '';
                $this->doQuery();
                if ( count( $this->mHist ) ) {
+                       if ( $this->mImg->isLocal() ) {
+                               // Do a batch existence check for user pages and talkpages
+                               $linkBatch = new LinkBatch();
+                               for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
+                                       $file = $this->mHist[$i];
+                                       $user = $file->getUser( 'text' );
+                                       $linkBatch->add( NS_USER, $user );
+                                       $linkBatch->add( NS_USER_TALK, $user );
+                               }
+                               $linkBatch->execute();
+                       }
+
                        $list = new ImageHistoryList( $this->mImagePage );
                        # Generate prev/next links
                        $navLink = $this->getNavigationBar();