Automattic\WooCommerce\Internal\Api

QueryCache::get_opcache_cache_dirpublic staticWC 1.0

Resolve the directory where OPcache cache files are written.

Defaults to a versioned subdirectory under wp-uploads so it inherits the writability guarantees WordPress places on uploads. Filterable for tests and unusual hosting layouts.

Method of the class: QueryCache{}

Returns

null. Nothing (null).

Usage

$result = QueryCache::get_opcache_cache_dir(): string;

QueryCache::get_opcache_cache_dir() code WC 10.9.1

public static function get_opcache_cache_dir(): string {
	$upload_dir = wp_get_upload_dir();
	$default    = trailingslashit( $upload_dir['basedir'] ) . self::OPCACHE_DIR_RELATIVE;

	/**
	 * Filters the directory where parsed GraphQL ASTs are written for OPcache.
	 *
	 * @since 10.9.0
	 *
	 * @param string $dir Default cache directory under wp-uploads.
	 */
	$dir = (string) apply_filters( 'woocommerce_graphql_opcache_cache_dir', $default );

	// Reject stream wrappers (e.g. phar://, http://) to keep file_put_contents,
	// rename, and include constrained to local filesystem paths.
	if ( '' === $dir || wp_is_stream( $dir ) ) {
		return '';
	}

	return $dir;
}