Yoast\WP\SEO\Commands

Index_Command::run_indexation_action │ protected │ Yoast 1.0

Runs an indexation action.

Метод класса: Index_Command{}

Хуков нет.

Возвращает

void. Ничего (null).

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->run_indexation_action( $name, $indexation_action, $interval );
$name(строка) (обязательный)
The name of the object to be indexed.
$indexation_action(Indexation_Action_Interface) (обязательный)
The indexation action.
$interval(int) (обязательный)
Number of microseconds (millionths of a second) to wait between index actions.

Код Index_Command::run_indexation_action() Yoast 28.9

protected function run_indexation_action( $name, Indexation_Action_Interface $indexation_action, $interval ) {
	$total = $indexation_action->get_total_unindexed();
	if ( $total > 0 ) {
		$limit    = $indexation_action->get_limit();
		$progress = Utils\make_progress_bar( 'Indexing ' . $name, $total );
		do {
			try {
				$indexables = $indexation_action->index();
			} catch ( Indexing_Failed_Exception $exception ) {
				$progress->finish();

				$previous = $exception->getPrevious();
				WP_CLI::error(
					\sprintf(
						'Could not optimize %1$s while indexing %2$s: %3$s',
						$exception->get_object_description(),
						$name,
						( $previous !== null ) ? $previous->getMessage() : $exception->getMessage(),
					),
				);

				return;
			}
			$count = \count( $indexables );
			$progress->tick( $count );
			\usleep( $interval );
			Utils\wp_clear_object_cache();
		} while ( $count >= $limit );
		$progress->finish();
	}
}