57 $status = StatusValue::newGood();
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 );
98 $status->merge( $subStatus );
99 if ( $subStatus->isOK() ) {
101 $entries = array_merge( $entries,
102 $fileOp->getJournalEntries( $oldPredicates, $predicates ) );
105 $status->success[$index] =
false;
106 ++$status->failCount;
107 if ( !$ignoreErrors ) {
113 if ( count( $curBatch ) ) {
114 $pPerformOps[] = $curBatch;
118 if ( count( $entries ) ) {
120 if ( !$subStatus->isOK() ) {
121 $status->merge( $subStatus );
127 if ( $ignoreErrors ) {
128 $status->setResult(
true, $status->value );
150 foreach ( $pPerformOps as $performOpsBatch ) {
155 foreach ( $performOpsBatch as $i => $fileOp ) {
156 $status->success[$i] =
false;
157 ++$status->failCount;
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];
191 $status->
merge( $subStatus );
192 if ( $subStatus->isOK() ) {
193 $status->success[$i] =
true;
194 ++$status->successCount;
196 $status->success[$i] =
false;
197 ++$status->failCount;