58 $status = StatusValue::newGood();
60 $n = count( $performOps );
61 if ( $n > self::MAX_BATCH_SIZE ) {
62 $status->fatal(
'backend-fail-batchsize', $n, self::MAX_BATCH_SIZE );
68 $ignoreErrors = !empty( $opts[
'force'] );
69 $journaled = empty( $opts[
'nonJournaled'] );
70 $maxConcurrency = isset( $opts[
'concurrency'] ) ? $opts[
'concurrency'] : 1;
79 foreach ( $performOps
as $index => $fileOp ) {
80 $backendName = $fileOp->getBackend()->getName();
81 $fileOp->setBatchId( $batchId );
84 if ( $fileOp->dependsOn( $curBatchDeps )
85 || count( $curBatch ) >= $maxConcurrency
86 || ( $backendName !== $lastBackend && count( $curBatch ) )
88 $pPerformOps[] = $curBatch;
92 $lastBackend = $backendName;
93 $curBatch[$index] = $fileOp;
95 $curBatchDeps = $fileOp->applyDependencies( $curBatchDeps );
97 $oldPredicates = $predicates;
98 $subStatus = $fileOp->precheck( $predicates );
100 if ( $subStatus->isOK() ) {
102 $entries = array_merge( $entries,
103 $fileOp->getJournalEntries( $oldPredicates, $predicates ) );
106 $status->success[$index] =
false;
108 if ( !$ignoreErrors ) {
114 if ( count( $curBatch ) ) {
115 $pPerformOps[] = $curBatch;
119 if ( count( $entries ) ) {
121 if ( !$subStatus->isOK() ) {
128 if ( $ignoreErrors ) {
151 foreach ( $pPerformOps
as $performOpsBatch ) {
156 foreach ( $performOpsBatch
as $i => $fileOp ) {
159 $performOpsBatch[$i]->logFailure(
'attempt_aborted' );
168 $backend = reset( $performOpsBatch )->getBackend();
172 foreach ( $performOpsBatch
as $i => $fileOp ) {
173 if ( !isset(
$status->success[$i] ) ) {
176 $subStatus = ( count( $performOpsBatch ) > 1 )
177 ? $fileOp->attemptAsync()
178 : $fileOp->attempt();
180 $opHandles[$i] = $subStatus->value;
182 $statuses[$i] = $subStatus;
187 $statuses = $statuses + $backend->executeOpHandlesInternal( $opHandles );
189 foreach ( $performOpsBatch
as $i => $fileOp ) {
190 if ( !isset(
$status->success[$i] ) ) {
191 $subStatus = $statuses[$i];
193 if ( $subStatus->isOK() ) {