90 $class = get_class(
$job );
92 $params =
$job->getParams();
94 $backlinkCache = MediaWikiServices::getInstance()->getBacklinkCacheFactory()
95 ->getBacklinkCache(
$title );
96 if ( isset( $params[
'pages'] ) || empty( $params[
'recursive'] ) ) {
99 wfWarn( __METHOD__ .
" called on {$job->getType()} leaf job (explosive recursion)." );
100 } elseif ( isset( $params[
'range'] ) ) {
102 $ranges = $params[
'range'][
'subranges'];
103 $realBSize = $params[
'range'][
'batchSize'];
106 $ranges = $backlinkCache->partition( $params[
'table'], $bSize );
110 $extraParams = $opts[
'params'] ?? [];
114 if ( isset( $ranges[0] ) ) {
115 list( $start, $end ) = $ranges[0];
116 $iter = $backlinkCache->getLinks( $params[
'table'], $start, $end );
117 $titles = iterator_to_array( $iter );
119 foreach ( array_chunk( $titles, $cSize ) as $titleBatch ) {
121 foreach ( $titleBatch as $tl ) {
122 $pages[$tl->getArticleID()] = [ $tl->getNamespace(), $tl->getDBkey() ];
124 $jobs[] =
new $class(
126 [
'pages' => $pages ] + $extraParams
131 if ( isset( $ranges[1] ) ) {
132 $jobs[] =
new $class(
136 'table' => $params[
'table'],
138 'start' => $ranges[1][0],
139 'end' => $ranges[count( $ranges ) - 1][1],
140 'batchSize' => $realBSize,
141 'subranges' => array_slice( $ranges, 1 )
144 'division' => isset( $params[
'division'] )
145 ? ( $params[
'division'] + 1 )