Migration_Status::should_run_migration()publicYoast 1.0

Checks if a given migration should be run.

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

Хуков нет.


true|false. Whether or not the migration should be run.


$Migration_Status = new Migration_Status();
$Migration_Status->should_run_migration( $name, $version );
$name(строка) (обязательный)
The name of the migration.
The current version.
По умолчанию: \WPSEO_VERSION

Код Migration_Status::should_run_migration() Yoast 21.6

public function should_run_migration( $name, $version = \WPSEO_VERSION ) {
	$migration_status = $this->get_migration_status( $name );

	// Check if we've attempted to run this migration in the past 10 minutes. If so, it may still be running.
	if ( \array_key_exists( 'lock', $migration_status ) ) {
		$timestamp = \strtotime( '-10 minutes' );

		return $timestamp > $migration_status['lock'];

	// Is the migration version less than the current version.
	return \version_compare( $migration_status['version'], $version, '<' );