id() ); $staging = $dir . '/staging/' . Format::CONTENT_DIR; $content = Paths::content(); $trash = $dir . '/trash'; if ( null === $job->cursor( 'tasks' ) ) { $job->setCursor( 'tasks', Mover::plan( $staging, (array) apply_filters( 'migratex_import_roots', self::DATA_ROOTS ) ) ); $job->setCursor( 'i', 0 ); } $tasks = (array) $job->cursor( 'tasks', array() ); $index = (int) $job->cursor( 'i', 0 ); try { while ( $index < count( $tasks ) && ! $budget->exhausted() ) { $relative = (string) $tasks[ $index ]; Mover::place( $staging . '/' . $relative, $content . '/' . $relative, $trash, $content, $job->id() ); ++$index; $job->setCursor( 'i', $index ); $job->setStageProgress( $index / max( 1, count( $tasks ) ) ); $job->setDetail( array( 'item' => $relative, 'done' => $index, 'total' => count( $tasks ), ) ); $budget->commit(); $budget->unit(); } } catch ( \RuntimeException $e ) { return StageResult::fail( 'om_files', $e->getMessage() ); } return $index < count( $tasks ) ? StageResult::more() : StageResult::next(); } }