ActionScheduler_wpPostStore::migration_dependencies_met()publicWC 1.0

Determine whether the post store can be migrated.

Method of the class: ActionScheduler_wpPostStore{}

Hooks from the method

Return

true|false.

Usage

$ActionScheduler_wpPostStore = new ActionScheduler_wpPostStore();
$ActionScheduler_wpPostStore->migration_dependencies_met( $setting );
$setting([type]) (required)
- Setting value.

ActionScheduler_wpPostStore::migration_dependencies_met() code WC 9.3.1

public function migration_dependencies_met( $setting ) {
	global $wpdb;

	$dependencies_met = get_transient( self::DEPENDENCIES_MET );
	if ( empty( $dependencies_met ) ) {
		$maximum_args_length = apply_filters( 'action_scheduler_maximum_args_length', 191 );
		$found_action        = $wpdb->get_var( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
			$wpdb->prepare(
				"SELECT ID FROM {$wpdb->posts} WHERE post_type = %s AND CHAR_LENGTH(post_content) > %d LIMIT 1",
				$maximum_args_length,
				self::POST_TYPE
			)
		);
		$dependencies_met    = $found_action ? 'no' : 'yes';
		set_transient( self::DEPENDENCIES_MET, $dependencies_met, DAY_IN_SECONDS );
	}

	return 'yes' === $dependencies_met ? $setting : false;
}