ActionScheduler_DBStore::db_supports_skip_lockedprivateWC 1.0

Determines whether the database supports using SKIP LOCKED. This logic mimicks the $wpdb::has_cap() logic.

SKIP_LOCKED support was added to MariaDB in 10.6.0 and to MySQL in 8.0.1

Method of the class: ActionScheduler_DBStore{}

Returns

true|false.

Usage

// private - for code of main (parent) class only
$result = $this->db_supports_skip_locked();

ActionScheduler_DBStore::db_supports_skip_locked() code WC 10.3.6

private function db_supports_skip_locked() {
	global $wpdb;
	$db_version     = $wpdb->db_version();
	$db_server_info = $wpdb->db_server_info();
	$is_mariadb     = ( false !== strpos( $db_server_info, 'MariaDB' ) );

	if ( $is_mariadb &&
	     '5.5.5' === $db_version &&
	     PHP_VERSION_ID < 80016 // PHP 8.0.15 or older.
	) {
		/*
		 * Account for MariaDB version being prefixed with '5.5.5-' on older PHP versions.
		 */
		$db_server_info = preg_replace( '/^5\.5\.5-(.*)/', '$1', $db_server_info );
		$db_version     = preg_replace( '/[^0-9.].*/', '', $db_server_info );
	}

	$is_supported = ( $is_mariadb && version_compare( $db_version, '10.6.0', '>=' ) ) ||
	                ( ! $is_mariadb && version_compare( $db_version, '8.0.1', '>=' ) );

	/**
	 * Filter whether the database supports the SKIP LOCKED modifier for queries.
	 *
	 * @param bool $is_supported Whether SKIP LOCKED is supported.
	 *
	 * @since 3.9.3
	 */
	return apply_filters( 'action_scheduler_db_supports_skip_locked', $is_supported );
}