Fix some IDEA errors in BacklinkJobUtils
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 1 Dec 2015 21:54:34 +0000 (13:54 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 1 Dec 2015 21:54:34 +0000 (13:54 -0800)
Change-Id: I0e61f93bc19c183442933dbb8192264838c1c9a1

includes/jobqueue/utils/BacklinkJobUtils.php

index c8e5df6..1586f89 100644 (file)
@@ -71,6 +71,7 @@ class BacklinkJobUtils {
 
                if ( isset( $params['pages'] ) || empty( $params['recursive'] ) ) {
                        $ranges = array(); // sanity; this is a leaf node
+                       $realBSize = 0;
                        wfWarn( __METHOD__ . " called on {$job->getType()} leaf job (explosive recursion)." );
                } elseif ( isset( $params['range'] ) ) {
                        // This is a range job to trigger the insertion of partitioned/title jobs...
@@ -88,8 +89,10 @@ class BacklinkJobUtils {
                // Combine the first range (of size $bSize) backlinks into leaf jobs
                if ( isset( $ranges[0] ) ) {
                        list( $start, $end ) = $ranges[0];
-                       $titles = $title->getBacklinkCache()->getLinks( $params['table'], $start, $end );
-                       foreach ( array_chunk( iterator_to_array( $titles ), $cSize ) as $titleBatch ) {
+                       $iter = $title->getBacklinkCache()->getLinks( $params['table'], $start, $end );
+                       $titles = iterator_to_array( $iter );
+                       /** @var Title[] $titleBatch */
+                       foreach ( array_chunk( $titles, $cSize ) as $titleBatch ) {
                                $pages = array();
                                foreach ( $titleBatch as $tl ) {
                                        $pages[$tl->getArticleId()] = array( $tl->getNamespace(), $tl->getDBKey() );