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 ) {
154 foreach ( $performOpsBatch as $i => $fileOp ) {
155 $status->success[$i] =
false;
156 ++$status->failCount;
157 $fileOp->logFailure(
'attempt_aborted' );
166 $backend = reset( $performOpsBatch )->getBackend();
170 foreach ( $performOpsBatch as $i => $fileOp ) {
171 if ( !isset( $status->success[$i] ) ) {
174 $subStatus = ( count( $performOpsBatch ) > 1 )
175 ? $fileOp->attemptAsync()
176 : $fileOp->attempt();
178 $opHandles[$i] = $subStatus->value;
180 $statuses[$i] = $subStatus;
185 $statuses += $backend->executeOpHandlesInternal( $opHandles );
187 foreach ( $performOpsBatch as $i => $fileOp ) {
188 if ( !isset( $status->success[$i] ) ) {
189 $subStatus = $statuses[$i];
190 $status->
merge( $subStatus );
191 if ( $subStatus->isOK() ) {
192 $status->success[$i] =
true;
193 ++$status->successCount;
195 $status->success[$i] =
false;
196 ++$status->failCount;