59 $n = count( $performOps );
60 if ( $n > self::MAX_BATCH_SIZE ) {
61 $status->fatal(
'backend-fail-batchsize', $n, self::MAX_BATCH_SIZE );
67 $ignoreErrors = !empty( $opts[
'force'] );
68 $journaled = empty( $opts[
'nonJournaled'] );
69 $maxConcurrency = $opts[
'concurrency'] ?? 1;
78 foreach ( $performOps as $index => $fileOp ) {
79 $backendName = $fileOp->getBackend()->getName();
80 $fileOp->setBatchId( $batchId );
83 if ( $fileOp->dependsOn( $curBatchDeps )
84 || count( $curBatch ) >= $maxConcurrency
85 || ( $backendName !== $lastBackend && count( $curBatch ) )
87 $pPerformOps[] = $curBatch;
91 $lastBackend = $backendName;
92 $curBatch[$index] = $fileOp;
94 $curBatchDeps = $fileOp->applyDependencies( $curBatchDeps );
96 $oldPredicates = $predicates;
97 $subStatus = $fileOp->precheck( $predicates );
99 if ( $subStatus->isOK() ) {
101 $entries = array_merge( $entries,
102 $fileOp->getJournalEntries( $oldPredicates, $predicates ) );
105 $status->success[$index] =
false;
107 if ( !$ignoreErrors ) {
113 if ( count( $curBatch ) ) {
114 $pPerformOps[] = $curBatch;
118 if ( count( $entries ) ) {
120 if ( !$subStatus->isOK() ) {
127 if ( $ignoreErrors ) {
150 foreach ( $pPerformOps as $performOpsBatch ) {
155 foreach ( $performOpsBatch as $i => $fileOp ) {
158 $performOpsBatch[$i]->logFailure(
'attempt_aborted' );
167 $backend = reset( $performOpsBatch )->getBackend();
171 foreach ( $performOpsBatch as $i => $fileOp ) {
172 if ( !isset(
$status->success[$i] ) ) {
175 $subStatus = ( count( $performOpsBatch ) > 1 )
176 ? $fileOp->attemptAsync()
177 : $fileOp->attempt();
179 $opHandles[$i] = $subStatus->value;
181 $statuses[$i] = $subStatus;
186 $statuses = $statuses + $backend->executeOpHandlesInternal( $opHandles );
188 foreach ( $performOpsBatch as $i => $fileOp ) {
189 if ( !isset(
$status->success[$i] ) ) {
190 $subStatus = $statuses[$i];
192 if ( $subStatus->isOK() ) {