61 $n = count( $performOps );
62 if (
$n > self::MAX_BATCH_SIZE ) {
63 $status->fatal(
'backend-fail-batchsize',
$n, self::MAX_BATCH_SIZE );
69 $ignoreErrors = !empty( $opts[
'force'] );
70 $journaled = empty( $opts[
'nonJournaled'] );
71 $maxConcurrency = isset( $opts[
'concurrency'] ) ? $opts[
'concurrency'] : 1;
77 $pPerformOps =
array();
80 foreach ( $performOps
as $index => $fileOp ) {
81 $backendName = $fileOp->getBackend()->getName();
82 $fileOp->setBatchId( $batchId );
85 if ( $fileOp->dependsOn( $curBatchDeps )
86 || count( $curBatch ) >= $maxConcurrency
87 || ( $backendName !== $lastBackend && count( $curBatch ) )
89 $pPerformOps[] = $curBatch;
93 $lastBackend = $backendName;
94 $curBatch[$index] = $fileOp;
96 $curBatchDeps = $fileOp->applyDependencies( $curBatchDeps );
98 $oldPredicates = $predicates;
99 $subStatus = $fileOp->precheck( $predicates );
100 $status->merge( $subStatus );
101 if ( $subStatus->isOK() ) {
103 $entries = array_merge( $entries,
104 $fileOp->getJournalEntries( $oldPredicates, $predicates ) );
107 $status->success[$index] =
false;
108 ++$status->failCount;
109 if ( !$ignoreErrors ) {
115 if ( count( $curBatch ) ) {
116 $pPerformOps[] = $curBatch;
120 if ( count( $entries ) ) {
122 if ( !$subStatus->isOK() ) {
127 if ( $ignoreErrors ) {
128 $status->setResult(
true, $status->value );
150 foreach ( $pPerformOps
as $performOpsBatch ) {
154 foreach ( $performOpsBatch
as $i => $fileOp ) {
155 $performOpsBatch[$i]->logFailure(
'attempt_aborted' );
160 $opHandles =
array();
162 $backend = reset( $performOpsBatch )->getBackend();
166 foreach ( $performOpsBatch
as $i => $fileOp ) {
167 if ( !isset( $status->success[$i] ) ) {
170 $subStatus = ( count( $performOpsBatch ) > 1 )
171 ? $fileOp->attemptAsync()
172 : $fileOp->attempt();
174 $opHandles[$i] = $subStatus->value;
176 $statuses[$i] = $subStatus;
181 $statuses = $statuses + $backend->executeOpHandlesInternal( $opHandles );
183 foreach ( $performOpsBatch
as $i => $fileOp ) {
184 if ( !isset( $status->success[$i] ) ) {
185 $subStatus = $statuses[$i];
186 $status->
merge( $subStatus );
187 if ( $subStatus->isOK() ) {
188 $status->success[$i] =
true;
189 ++$status->successCount;
191 $status->success[$i] =
false;
192 ++$status->failCount;