Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Caching
File: CacheException.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Automattic\WooCommerce\Caching;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* Exception thrown by classes derived from ObjectCache.
[5] Fix | Delete
*/
[6] Fix | Delete
class CacheException extends \Exception {
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Error messages.
[10] Fix | Delete
*
[11] Fix | Delete
* @var array
[12] Fix | Delete
*/
[13] Fix | Delete
private $errors;
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* The object that threw the exception.
[17] Fix | Delete
*
[18] Fix | Delete
* @var ObjectCache
[19] Fix | Delete
*/
[20] Fix | Delete
private $thrower;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* The id of the cached object, if available.
[24] Fix | Delete
*
[25] Fix | Delete
* @var int|string|null
[26] Fix | Delete
*/
[27] Fix | Delete
private $cached_id;
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* Creates a new instance of the class.
[31] Fix | Delete
*
[32] Fix | Delete
* @param string $message The exception message.
[33] Fix | Delete
* @param ObjectCache $thrower The object that is throwing the exception.
[34] Fix | Delete
* @param int|string|null $cached_id The involved cached object id, if available.
[35] Fix | Delete
* @param array|null $errors An array of error messages, if available.
[36] Fix | Delete
* @param mixed $code An error code, if available.
[37] Fix | Delete
* @param \Throwable|null $previous The previous exception, if available.
[38] Fix | Delete
*/
[39] Fix | Delete
public function __construct( string $message, ObjectCache $thrower, $cached_id = null, ?array $errors = null, $code = 0, ?\Throwable $previous = null ) {
[40] Fix | Delete
$this->errors = $errors ?? array();
[41] Fix | Delete
$this->thrower = $thrower;
[42] Fix | Delete
$this->cached_id = $cached_id;
[43] Fix | Delete
[44] Fix | Delete
parent::__construct( $message, $code, $previous );
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Get a string representation of the exception object.
[49] Fix | Delete
*
[50] Fix | Delete
* @return string String representation of the exception object.
[51] Fix | Delete
*/
[52] Fix | Delete
public function __toString(): string {
[53] Fix | Delete
$cached_id_part = $this->cached_id ? ", id: {$this->cached_id}" : '';
[54] Fix | Delete
return "CacheException: [{$this->thrower->get_object_type()}{$cached_id_part}]: {$this->message}";
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Gets the array of error messages passed to the exception constructor.
[59] Fix | Delete
*
[60] Fix | Delete
* @return array Error messages passed to the exception constructor.
[61] Fix | Delete
*/
[62] Fix | Delete
public function get_errors(): array {
[63] Fix | Delete
return $this->errors;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Gets the object that threw the exception as passed to the exception constructor.
[68] Fix | Delete
*
[69] Fix | Delete
* @return object The object that threw the exception.
[70] Fix | Delete
*/
[71] Fix | Delete
public function get_thrower(): object {
[72] Fix | Delete
return $this->thrower;
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
/**
[76] Fix | Delete
* Gets the id of the cached object as passed to the exception constructor.
[77] Fix | Delete
*
[78] Fix | Delete
* @return int|string|null The id of the cached object.
[79] Fix | Delete
*/
[80] Fix | Delete
public function get_cached_id() {
[81] Fix | Delete
return $this->cached_id;
[82] Fix | Delete
}
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function