54 public static function attempt( array $performOps, array $opts ) {
55 $status = StatusValue::newGood();
57 $n = count( $performOps );
58 if ( $n > self::MAX_BATCH_SIZE ) {
59 $status->fatal(
'backend-fail-batchsize', $n, self::MAX_BATCH_SIZE );
64 $ignoreErrors = !empty( $opts[
'force'] );
65 $maxConcurrency = $opts[
'concurrency'] ?? 1;
73 foreach ( $performOps as $index => $fileOp ) {
74 $backendName = $fileOp->getBackend()->getName();
77 if ( $fileOp->dependsOn( $curBatchDeps )
78 || count( $curBatch ) >= $maxConcurrency
79 || ( $backendName !== $lastBackend && count( $curBatch ) )
81 $pPerformOps[] = $curBatch;
85 $lastBackend = $backendName;
86 $curBatch[$index] = $fileOp;
88 $curBatchDeps = $fileOp->applyDependencies( $curBatchDeps );
90 $subStatus = $fileOp->precheck( $predicates );
91 $status->merge( $subStatus );
92 if ( !$subStatus->isOK() ) {
94 $status->success[$index] =
false;
96 if ( !$ignoreErrors ) {
102 if ( count( $curBatch ) ) {
103 $pPerformOps[] = $curBatch;
106 if ( $ignoreErrors ) {
107 $status->setResult(
true, $status->value );
129 foreach ( $pPerformOps as $performOpsBatch ) {
133 foreach ( $performOpsBatch as $i => $fileOp ) {
134 $status->success[$i] =
false;
135 ++$status->failCount;
136 $fileOp->logFailure(
'attempt_aborted' );
145 $backend = reset( $performOpsBatch )->getBackend();
149 foreach ( $performOpsBatch as $i => $fileOp ) {
150 if ( !isset( $status->success[$i] ) ) {
153 $subStatus = ( count( $performOpsBatch ) > 1 )
154 ? $fileOp->attemptAsync()
155 : $fileOp->attempt();
157 $opHandles[$i] = $subStatus->value;
159 $statuses[$i] = $subStatus;
164 $statuses += $backend->executeOpHandlesInternal( $opHandles );
166 foreach ( $performOpsBatch as $i => $fileOp ) {
167 if ( !isset( $status->success[$i] ) ) {
168 $subStatus = $statuses[$i];
169 $status->
merge( $subStatus );
170 if ( $subStatus->isOK() ) {
171 $status->success[$i] =
true;
172 ++$status->successCount;
174 $status->success[$i] =
false;
175 ++$status->failCount;