Automattic\WooCommerce\Internal\Api

QueryCache::compute_is_opcache_usableprivateWC 1.0

Underlying capability check for the OPcache file backend.

Requires the OPcache extension to be loaded and enabled, and the cache directory to exist (or be creatable) and be writable.

Method of the class: QueryCache{}

No Hooks.

Returns

null. Nothing (null).

Usage

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

QueryCache::compute_is_opcache_usable() code WC 10.9.1

private function compute_is_opcache_usable(): bool {
	if ( ! function_exists( 'opcache_get_status' ) || ! ini_get( 'opcache.enable' ) ) {
		return false;
	}

	// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- opcache.restrict_api raises E_WARNING when the calling path is disallowed; the false return is handled below.
	$status = @opcache_get_status( false );
	if ( ! is_array( $status ) || empty( $status['opcache_enabled'] ) ) {
		return false;
	}

	return $this->ensure_opcache_dir_writable();
}