61 public static function attempt( array $performOps, array $opts ) {
62 $status = StatusValue::newGood();
64 $n = count( $performOps );
65 if ( $n > self::MAX_BATCH_SIZE ) {
66 $status->fatal(
'backend-fail-batchsize', $n, self::MAX_BATCH_SIZE );
71 $ignoreErrors = !empty( $opts[
'force'] );
72 $maxConcurrency = $opts[
'concurrency'] ?? 1;
76 $curBatchDeps = FileOp::newDependencies();
80 foreach ( $performOps as $index => $fileOp ) {
81 $backendName = $fileOp->getBackend()->getName();
84 if ( $fileOp->dependsOn( $curBatchDeps )
85 || count( $curBatch ) >= $maxConcurrency
86 || ( $backendName !== $lastBackend && count( $curBatch ) )
88 $pPerformOps[] = $curBatch;
90 $curBatchDeps = FileOp::newDependencies();
92 $lastBackend = $backendName;
93 $curBatch[$index] = $fileOp;
95 $curBatchDeps = $fileOp->applyDependencies( $curBatchDeps );
97 $subStatus = $fileOp->precheck( $predicates );
98 $status->merge( $subStatus );
99 if ( !$subStatus->isOK() ) {
101 $status->success[$index] =
false;
102 ++$status->failCount;
103 if ( !$ignoreErrors ) {
109 if ( count( $curBatch ) ) {
110 $pPerformOps[] = $curBatch;
113 if ( $ignoreErrors ) {
114 $status->setResult(
true, $status->value );
136 foreach ( $pPerformOps as $performOpsBatch ) {
140 foreach ( $performOpsBatch as $i => $fileOp ) {
141 $status->success[$i] =
false;
142 ++$status->failCount;
143 $fileOp->logFailure(
'attempt_aborted' );
152 $backend = reset( $performOpsBatch )->getBackend();
156 foreach ( $performOpsBatch as $i => $fileOp ) {
157 if ( !isset( $status->success[$i] ) ) {
160 $subStatus = ( count( $performOpsBatch ) > 1 )
161 ? $fileOp->attemptAsync()
162 : $fileOp->attempt();
164 $opHandles[$i] = $subStatus->value;
166 $statuses[$i] = $subStatus;
171 $statuses += $backend->executeOpHandlesInternal( $opHandles );
173 foreach ( $performOpsBatch as $i => $fileOp ) {
174 if ( !isset( $status->success[$i] ) ) {
175 $subStatus = $statuses[$i];
176 $status->
merge( $subStatus );
177 if ( $subStatus->isOK() ) {
178 $status->success[$i] =
true;
179 ++$status->successCount;
181 $status->success[$i] =
false;
182 ++$status->failCount;