PluginProbe
The WP Remote WordPress Plugin / trunk
The WP Remote WordPress Plugin vtrunk
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
← All changes | php_error_monitoring/monitoring.php +25 -10 5.68trunk View file →
@@ -20,18 +20,23 @@
20 20 public static function init() {
21 21 if (self::$initialized) {
22 22 return;
23 23 }
24 + include_once dirname(__FILE__) . '/../wp_settings.php';
25 + include_once dirname(__FILE__) . '/../wp_db.php';
26 + include_once dirname(__FILE__) . '/../info.php';
27 +
28 + self::$settings = new WPRWPSettings();
29 + self::$db = new WPRWPDb();
30 + self::$info = new WPRInfo(self::$settings);
31 +
32 + if (self::$info->isServiceActive('php_error_monitoring')) {
33 + add_action('wpr_clear_php_error_config', array('WPRWPPHPErrorMonitoring', 'clearConfig'));
34 + }
35 +
24 36 include_once ABSPATH . 'wp-admin/includes/plugin.php';
25 37
26 38 if (is_plugin_active('wpremote/plugin.php')) {
27 - include_once dirname(__FILE__) . '/../wp_settings.php';
28 - include_once dirname(__FILE__) . '/../wp_db.php';
29 - include_once dirname(__FILE__) . '/../info.php';
30 - self::$settings = new WPRWPSettings();
31 - self::$db = new WPRWPDb();
32 - self::$info = new WPRInfo(self::$settings);
33 -
34 39 if (self::$info->isServiceActive('php_error_monitoring') && self::$info->hasValidDBVersion()) {
35 40 self::updateDefaultValues();
36 41 self::setPhpErrorHandler();
37 42 self::$initialized = true;
@@ -38,8 +43,12 @@
38 43 }
39 44 }
40 45 }
41 46
47 + public static function clearConfig() {
48 + self::$db->dropBVTable(self::ERROR_TABLE);
49 + }
50 +
42 51 public static function isValidErrorLevel($error_level) {
43 52 return is_int($error_level) && ($error_level & E_ALL) === $error_level;
44 53 }
45 54
@@ -72,8 +81,9 @@
72 81 }
73 82 }
74 83
75 84 public static function setPhpErrorHandler() {
85 + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler -- Custom error handling
76 86 set_error_handler(array(self::class, 'errorHandler'), self::$error_level);
77 87 register_shutdown_function(array(self::class, 'handleShutdown'));
78 88 }
79 89
@@ -114,8 +124,9 @@
114 124 $data = array();
115 125
116 126 $serialized_backtrace = '';
117 127 if (self::$include_backtrace) {
128 + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace -- Needed for stack trace functionality
118 129 $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, self::$max_backtrace_frames);
119 130
120 131 $keys = array_flip(array('file', 'line', 'function'));
121 132 foreach ($backtrace as &$frame) {
@@ -128,9 +139,9 @@
128 139
129 140 $data["md5"] = md5($code . '-' . $message . '-' . $line . '-' . $file . '-' . $serialized_backtrace);
130 141
131 142 if (!self::canCaptureError($data['md5'])) {
132 - return;
143 + return false;
133 144 }
134 145
135 146 $data["error_code"] = $code;
136 147 $data["error_message"] = $message;
@@ -135,12 +146,16 @@
135 146 $data["error_code"] = $code;
136 147 $data["error_message"] = $message;
137 148 $data["error_line"] = $line;
138 149 $data["error_file"] = $file;
139 - $uri = array_key_exists('REQUEST_URI', $_SERVER) ? $_SERVER['REQUEST_URI'] : '';
150 + $uri = WPRHelper::getRawParam('SERVER', 'REQUEST_URI');
151 + if (!isset($uri)) {
152 + $uri = "";
153 + }
140 154 $data["request_path"] = parse_url($uri, PHP_URL_PATH);
141 155 $data["request_id"] = WPRInfo::getRequestID();
142 156
143 157 self::saveError(maybe_serialize($data));
158 + return false;
144 159 }
145 160 }
146 -endif;
161 +endif;