91 $class = get_class(
$job );
93 $params =
$job->getParams();
95 $backlinkCache = MediaWikiServices::getInstance()->getBacklinkCacheFactory()
96 ->getBacklinkCache(
$title );
97 if ( isset( $params[
'pages'] ) || empty( $params[
'recursive'] ) ) {
101 wfWarn( __METHOD__ .
" called on {$job->getType()} leaf job (explosive recursion)." );
102 } elseif ( isset( $params[
'range'] ) ) {
104 $ranges = $params[
'range'][
'subranges'];
105 $realBSize = $params[
'range'][
'batchSize'];
108 $ranges = $backlinkCache->partition( $params[
'table'], $bSize );
112 $extraParams = $opts[
'params'] ?? [];
116 if ( isset( $ranges[0] ) ) {
117 [ $start, $end ] = $ranges[0];
119 $iter = $backlinkCache->getLinkPages( $params[
'table'], $start, $end );
120 $pageSources = iterator_to_array( $iter );
122 foreach ( array_chunk( $pageSources, $cSize ) as $pageBatch ) {
124 foreach ( $pageBatch as $page ) {
125 $pages[$page->getId()] = [ $page->getNamespace(), $page->getDBkey() ];
127 $jobs[] =
new $class(
129 [
'pages' => $pages ] + $extraParams
134 if ( isset( $ranges[1] ) ) {
135 $jobs[] =
new $class(
139 'table' => $params[
'table'],
141 'start' => $ranges[1][0],
142 'end' => $ranges[count( $ranges ) - 1][1],
143 'batchSize' => $realBSize,
144 'subranges' => array_slice( $ranges, 1 )
147 'division' => isset( $params[
'division'] )
148 ? ( $params[
'division'] + 1 )