X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fjobqueue%2Futils%2FBacklinkJobUtils.php;h=7f500554bdd6ee942fae2b704cb79c1d8646b71f;hb=8472c6344819b79051bf947f0f2142e24bc8aba5;hp=1770ac75e4f52e1f5274f61bab891963dc5efac7;hpb=23299ca8790bcf1aebcf54e0932b94338e630474;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/jobqueue/utils/BacklinkJobUtils.php b/includes/jobqueue/utils/BacklinkJobUtils.php index 1770ac75e4..7f500554bd 100644 --- a/includes/jobqueue/utils/BacklinkJobUtils.php +++ b/includes/jobqueue/utils/BacklinkJobUtils.php @@ -85,13 +85,13 @@ class BacklinkJobUtils { * @param array $opts Optional parameter map * @return Job[] List of Job objects */ - public static function partitionBacklinkJob( Job $job, $bSize, $cSize, $opts = array() ) { + public static function partitionBacklinkJob( Job $job, $bSize, $cSize, $opts = [] ) { $class = get_class( $job ); $title = $job->getTitle(); $params = $job->getParams(); if ( isset( $params['pages'] ) || empty( $params['recursive'] ) ) { - $ranges = array(); // sanity; this is a leaf node + $ranges = []; // sanity; this is a leaf node $realBSize = 0; wfWarn( __METHOD__ . " called on {$job->getType()} leaf job (explosive recursion)." ); } elseif ( isset( $params['range'] ) ) { @@ -104,9 +104,9 @@ class BacklinkJobUtils { $realBSize = $bSize; } - $extraParams = isset( $opts['params'] ) ? $opts['params'] : array(); + $extraParams = isset( $opts['params'] ) ? $opts['params'] : []; - $jobs = array(); + $jobs = []; // Combine the first range (of size $bSize) backlinks into leaf jobs if ( isset( $ranges[0] ) ) { list( $start, $end ) = $ranges[0]; @@ -114,13 +114,13 @@ class BacklinkJobUtils { $titles = iterator_to_array( $iter ); /** @var Title[] $titleBatch */ foreach ( array_chunk( $titles, $cSize ) as $titleBatch ) { - $pages = array(); + $pages = []; foreach ( $titleBatch as $tl ) { - $pages[$tl->getArticleId()] = array( $tl->getNamespace(), $tl->getDBKey() ); + $pages[$tl->getArticleID()] = [ $tl->getNamespace(), $tl->getDBkey() ]; } $jobs[] = new $class( $title, // maintain parent job title - array( 'pages' => $pages ) + $extraParams + [ 'pages' => $pages ] + $extraParams ); } } @@ -128,16 +128,20 @@ class BacklinkJobUtils { if ( isset( $ranges[1] ) ) { $jobs[] = new $class( $title, // maintain parent job title - array( + [ 'recursive' => true, 'table' => $params['table'], - 'range' => array( + 'range' => [ 'start' => $ranges[1][0], 'end' => $ranges[count( $ranges ) - 1][1], 'batchSize' => $realBSize, 'subranges' => array_slice( $ranges, 1 ) - ), - ) + $extraParams + ], + // Track how many times the base job divided for debugging + 'division' => isset( $params['division'] ) + ? ( $params['division'] + 1 ) + : 1 + ] + $extraParams ); }