Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/worker/src/MWP/Debug
File: ErrorCatcher.php
<?php
[0] Fix | Delete
/*
[1] Fix | Delete
* This file is part of the ManageWP Worker plugin.
[2] Fix | Delete
*
[3] Fix | Delete
* (c) ManageWP LLC <contact@managewp.com>
[4] Fix | Delete
*
[5] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[6] Fix | Delete
* file that was distributed with this source code.
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
class MWP_Debug_ErrorCatcher
[10] Fix | Delete
{
[11] Fix | Delete
private $errorMessage;
[12] Fix | Delete
[13] Fix | Delete
private $registered;
[14] Fix | Delete
[15] Fix | Delete
public function handleError($code, $message, $file = '', $line = 0, $context = array())
[16] Fix | Delete
{
[17] Fix | Delete
if (is_string($this->registered) && !($message = preg_replace('{^'.$this->registered.'\(.*?\): }i', '', $message))) {
[18] Fix | Delete
return;
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
$this->errorMessage = $message;
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
public function getErrorMessage()
[25] Fix | Delete
{
[26] Fix | Delete
return $this->errorMessage;
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
public function yieldErrorMessage($unRegister = false)
[30] Fix | Delete
{
[31] Fix | Delete
$message = $this->errorMessage;
[32] Fix | Delete
$this->errorMessage = null;
[33] Fix | Delete
[34] Fix | Delete
if ($unRegister) {
[35] Fix | Delete
$this->unRegister();
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
return $message;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Set the $capture parameter to "true" to capture any error message; or to a function name
[43] Fix | Delete
* to capture only error messages for that function. It will rely on PHP's standard error
[44] Fix | Delete
* reporting which always starts with the name of the function that generated the error.
[45] Fix | Delete
*
[46] Fix | Delete
* @param bool|string $capture
[47] Fix | Delete
*/
[48] Fix | Delete
public function register($capture = true)
[49] Fix | Delete
{
[50] Fix | Delete
if ($this->registered) {
[51] Fix | Delete
throw new LogicException('The error catcher is already registered.');
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
if ($capture !== true && (!is_string($capture) || empty($capture))) {
[55] Fix | Delete
throw new InvalidArgumentException('The "capture" must be boolean true or a non-empty string.');
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
$this->registered = $capture;
[59] Fix | Delete
$this->errorMessage = null;
[60] Fix | Delete
set_error_handler(array($this, 'handleError'));
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
public function unRegister()
[64] Fix | Delete
{
[65] Fix | Delete
if (!$this->registered) {
[66] Fix | Delete
throw new LogicException('The error catcher is not registered.');
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
$this->registered = false;
[70] Fix | Delete
restore_error_handler();
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
public function __destruct()
[74] Fix | Delete
{
[75] Fix | Delete
if ($this->registered) {
[76] Fix | Delete
$this->unRegister();
[77] Fix | Delete
}
[78] Fix | Delete
}
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function