WC_Install::update()private staticWC 1.0

Push all needed DB updates to the queue for processing.

Method of the class: WC_Install{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = WC_Install::update();

WC_Install::update() code WC 8.7.0

private static function update() {
	$current_db_version = get_option( 'woocommerce_db_version' );
	$loop               = 0;

	foreach ( self::get_db_update_callbacks() as $version => $update_callbacks ) {
		if ( version_compare( $current_db_version, $version, '<' ) ) {
			foreach ( $update_callbacks as $update_callback ) {
				WC()->queue()->schedule_single(
					time() + $loop,
					'woocommerce_run_update_callback',
					array(
						'update_callback' => $update_callback,
					),
					'woocommerce-db-updates'
				);
				$loop++;
			}
		}
	}

	// After the callbacks finish, update the db version to the current WC version.
	$current_wc_version = WC()->version;
	if ( version_compare( $current_db_version, $current_wc_version, '<' ) &&
		! WC()->queue()->get_next( 'woocommerce_update_db_to_current_version' ) ) {
		WC()->queue()->schedule_single(
			time() + $loop,
			'woocommerce_update_db_to_current_version',
			array(
				'version' => $current_wc_version,
			),
			'woocommerce-db-updates'
		);
	}
}