88 $class = get_class(
$job );
89 $title =
$job->getTitle();
92 $backlinkCache = MediaWikiServices::getInstance()->getBacklinkCacheFactory()
93 ->getBacklinkCache( $title );
94 if ( isset(
$params[
'pages'] ) || empty(
$params[
'recursive'] ) ) {
98 wfWarn( __METHOD__ .
" called on {$job->getType()} leaf job (explosive recursion)." );
99 } elseif ( isset(
$params[
'range'] ) ) {
101 $ranges =
$params[
'range'][
'subranges'];
102 $realBSize =
$params[
'range'][
'batchSize'];
105 $ranges = $backlinkCache->partition(
$params[
'table'], $bSize );
109 $extraParams = $opts[
'params'] ?? [];
113 if ( isset( $ranges[0] ) ) {
114 $start = $ranges[0][0];
115 $end = isset( $ranges[1] ) ? $ranges[1][0] - 1 :
false;
117 $iter = $backlinkCache->getLinkPages(
$params[
'table'], $start, $end );
118 $pageSources = iterator_to_array( $iter );
120 foreach ( array_chunk( $pageSources, $cSize ) as $pageBatch ) {
122 foreach ( $pageBatch as $page ) {
123 $pages[$page->getId()] = [ $page->getNamespace(), $page->getDBkey() ];
125 $jobs[] =
new $class(
127 [
'pages' => $pages ] + $extraParams
132 if ( isset( $ranges[1] ) ) {
133 $jobs[] =
new $class(
139 'start' => $ranges[1][0],
140 'end' => $ranges[count( $ranges ) - 1][1],
141 'batchSize' => $realBSize,
142 'subranges' => array_slice( $ranges, 1 )
145 'division' => isset(
$params[
'division'] )