HEX
Server: nginx/1.20.1
System: Linux VM-0-8-centos 3.10.0-1160.11.1.el7.x86_64 #1 SMP Fri Dec 18 16:34:56 UTC 2020 x86_64
User: www (1000)
PHP: 7.3.29
Disabled: passthru,system,chroot,chgrp,chown,shell_exec,popen,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,popepassthru,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.ycfawu.com/wp-content/plugins/woocommerce/src/Caches/OrderCacheController.php
<?php

namespace Automattic\WooCommerce\Caches;

use Automattic\WooCommerce\Internal\Features\FeaturesController;
use Automattic\WooCommerce\Internal\Traits\AccessiblePrivateMethods;
use Automattic\WooCommerce\Utilities\OrderUtil;

/**
 * A class to control the usage of the orders cache.
 */
class OrderCacheController {

	use AccessiblePrivateMethods;

	/**
	 * The orders cache to use.
	 *
	 * @var OrderCache
	 */
	private $order_cache;

	/**
	 * The orders cache to use.
	 *
	 * @var FeaturesController
	 */
	private $features_controller;

	/**
	 * The backup value of the cache usage enable status, stored while the cache is temporarily disabled.
	 *
	 * @var null|bool
	 */
	private $orders_cache_usage_backup = null;

	/**
	 * Class initialization, invoked by the DI container.
	 *
	 * @internal
	 * @param OrderCache $order_cache The order cache engine to use.
	 */
	final public function init( OrderCache $order_cache ) {
		$this->order_cache = $order_cache;
	}

	/**
	 * Whether order cache usage is enabled. Currently, linked to custom orders' table usage.
	 *
	 * @return bool True if the order cache is enabled.
	 */
	public function orders_cache_usage_is_enabled(): bool {
		return OrderUtil::custom_orders_table_usage_is_enabled();
	}

	/**
	 * Temporarily disable the order cache if it's enabled.
	 *
	 * This is a purely in-memory operation: a variable is created with the value
	 * of the current enable status for the feature, and this variable
	 * is checked by orders_cache_usage_is_enabled. In the next request the
	 * feature will be again enabled or not depending on how the feature is set.
	 */
	public function temporarily_disable_orders_cache_usage(): void {
		if ( $this->orders_cache_usage_is_temporarly_disabled() ) {
			return;
		}

		$this->orders_cache_usage_backup = $this->orders_cache_usage_is_enabled();
	}

	/**
	 * Check if the order cache has been temporarily disabled.
	 *
	 * @return bool True if the order cache is currently temporarily disabled.
	 */
	public function orders_cache_usage_is_temporarly_disabled(): bool {
		return null !== $this->orders_cache_usage_backup;
	}

	/**
	 * Restore the order cache usage that had been temporarily disabled.
	 */
	public function maybe_restore_orders_cache_usage(): void {
		$this->orders_cache_usage_backup = null;
	}
}