| @@ -2,9 +2,8 @@ | ||
| 2 | 2 | namespace Elementor\Core\Logger; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Core\Base\Module as BaseModule; |
| 5 | 5 | use Elementor\Core\Common\Modules\Ajax\Module; |
| 6 | -use Elementor\Core\Editor\Editor; | |
| 7 | 6 | use Elementor\Core\Logger\Loggers\Logger_Interface; |
| 8 | 7 | use Elementor\Core\Logger\Items\PHP; |
| 9 | 8 | use Elementor\Core\Logger\Items\JS; |
| 10 | 9 | use Elementor\Plugin; |
| @@ -11,9 +10,9 @@ | ||
| 11 | 10 | use Elementor\Modules\System_Info\Module as System_Info; |
| 12 | 11 | use Elementor\Utils; |
| 13 | 12 | |
| 14 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 15 | - exit; // Exit if accessed directly. | |
| 14 | + exit; // Exit if accessed directly | |
| 16 | 15 | } |
| 17 | 16 | |
| 18 | 17 | class Manager extends BaseModule { |
| 19 | 18 | |
| @@ -54,13 +53,8 @@ | ||
| 54 | 53 | } |
| 55 | 54 | } |
| 56 | 55 | |
| 57 | 56 | public function rest_error_handler( $error_number, $error_message, $error_file, $error_line ) { |
| 58 | - // Temporary solution until all PHP notices will be fixed in the core and pro. | |
| 59 | - if ( Utils::is_wp_cli() ) { | |
| 60 | - return null; | |
| 61 | - } | |
| 62 | - | |
| 63 | 57 | $error = new \WP_Error( $error_number, $error_message, [ |
| 64 | 58 | 'type' => $error_number, |
| 65 | 59 | 'message' => $error_message, |
| 66 | 60 | 'file' => $error_file, |
| @@ -71,19 +65,13 @@ | ||
| 71 | 65 | // Do execute PHP internal error handler. |
| 72 | 66 | return false; |
| 73 | 67 | } |
| 74 | 68 | |
| 75 | - $is_an_error = in_array( // It can be notice or warning | |
| 76 | - $error_number, | |
| 77 | - [ E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR ], | |
| 78 | - true | |
| 79 | - ); | |
| 80 | - | |
| 81 | 69 | $error_data = $error->get_error_data(); |
| 82 | 70 | |
| 83 | 71 | // TODO: This part should be modular, temporary hard-coded. |
| 84 | 72 | // Notify $e.data. |
| 85 | - if ( $is_an_error && ! headers_sent() ) { | |
| 73 | + if ( ! headers_sent() ) { | |
| 86 | 74 | header( 'Content-Type: application/json; charset=UTF-8' ); |
| 87 | 75 | |
| 88 | 76 | http_response_code( 500 ); |
| 89 | 77 | |
| @@ -95,9 +83,9 @@ | ||
| 95 | 83 | ] ); |
| 96 | 84 | } |
| 97 | 85 | } |
| 98 | 86 | |
| 99 | - $this->shutdown( $error_data, $is_an_error ); | |
| 87 | + $this->shutdown( $error_data, true ); | |
| 100 | 88 | } |
| 101 | 89 | |
| 102 | 90 | public function register_error_handler() { |
| 103 | 91 | set_error_handler( [ $this, 'rest_error_handler' ], E_ALL ); |
| @@ -117,8 +105,9 @@ | ||
| 117 | 105 | * |
| 118 | 106 | * Log Elementor errors and save them in the database. |
| 119 | 107 | * |
| 120 | 108 | * Fired by `wp_ajax_elementor_js_log` action. |
| 109 | + * | |
| 121 | 110 | */ |
| 122 | 111 | public function js_log() { |
| 123 | 112 | /** @var Module $ajax */ |
| 124 | 113 | $ajax = Plugin::$instance->common->get_component( 'ajax' ); |
| @@ -127,21 +116,15 @@ | ||
| 127 | 116 | if ( ! $ajax->verify_request_nonce() || empty( $_POST['data'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 128 | 117 | wp_send_json_error(); |
| 129 | 118 | } |
| 130 | 119 | |
| 131 | - if ( ! current_user_can( Editor::EDITING_CAPABILITY ) ) { | |
| 132 | - wp_send_json_error( 'Permission denied' ); | |
| 133 | - } | |
| 134 | - | |
| 135 | 120 | // PHPCS - See comment above. |
| 136 | - $data = Utils::get_super_global_value( $_POST, 'data' ) ?? []; // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 137 | - | |
| 138 | - array_walk_recursive( $data, function( &$value ) { | |
| 121 | + array_walk_recursive( $_POST['data'], function( &$value ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 139 | 122 | $value = sanitize_text_field( $value ); |
| 140 | 123 | } ); |
| 141 | 124 | |
| 142 | 125 | // PHPCS - See comment above. |
| 143 | - foreach ( $data as $error ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 126 | + foreach ( $_POST['data'] as $error ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 144 | 127 | $error['type'] = Logger_Interface::LEVEL_ERROR; |
| 145 | 128 | |
| 146 | 129 | if ( ! empty( $error['customFields'] ) ) { |
| 147 | 130 | $error['meta'] = $error['customFields']; |
| @@ -153,10 +136,10 @@ | ||
| 153 | 136 | |
| 154 | 137 | wp_send_json_success(); |
| 155 | 138 | } |
| 156 | 139 | |
| 157 | - public function register_logger( $name, $class_name ) { | |
| 158 | - $this->loggers[ $name ] = $class_name; | |
| 140 | + public function register_logger( $name, $class ) { | |
| 141 | + $this->loggers[ $name ] = $class; | |
| 159 | 142 | } |
| 160 | 143 | |
| 161 | 144 | public function set_default_logger( $name ) { |
| 162 | 145 | if ( ! empty( $this->loggers[ $name ] ) ) { |
| @@ -199,9 +182,9 @@ | ||
| 199 | 182 | } |
| 200 | 183 | |
| 201 | 184 | /** |
| 202 | 185 | * @param string $message |
| 203 | - * @param array $args | |
| 186 | + * @param array $args | |
| 204 | 187 | * |
| 205 | 188 | * @return void |
| 206 | 189 | */ |
| 207 | 190 | public function info( $message, $args = [] ) { |
| @@ -209,9 +192,9 @@ | ||
| 209 | 192 | } |
| 210 | 193 | |
| 211 | 194 | /** |
| 212 | 195 | * @param string $message |
| 213 | - * @param array $args | |
| 196 | + * @param array $args | |
| 214 | 197 | * |
| 215 | 198 | * @return void |
| 216 | 199 | */ |
| 217 | 200 | public function notice( $message, $args = [] ) { |
| @@ -219,9 +202,9 @@ | ||
| 219 | 202 | } |
| 220 | 203 | |
| 221 | 204 | /** |
| 222 | 205 | * @param string $message |
| 223 | - * @param array $args | |
| 206 | + * @param array $args | |
| 224 | 207 | * |
| 225 | 208 | * @return void |
| 226 | 209 | */ |
| 227 | 210 | public function warning( $message, $args = [] ) { |
| @@ -229,9 +212,9 @@ | ||
| 229 | 212 | } |
| 230 | 213 | |
| 231 | 214 | /** |
| 232 | 215 | * @param string $message |
| 233 | - * @param array $args | |
| 216 | + * @param array $args | |
| 234 | 217 | * |
| 235 | 218 | * @return void |
| 236 | 219 | */ |
| 237 | 220 | public function error( $message, $args = [] ) { |
| @@ -245,8 +228,9 @@ | ||
| 245 | 228 | E_USER_ERROR => Logger_Interface::LEVEL_ERROR, |
| 246 | 229 | E_COMPILE_ERROR => Logger_Interface::LEVEL_ERROR, |
| 247 | 230 | E_RECOVERABLE_ERROR => Logger_Interface::LEVEL_ERROR, |
| 248 | 231 | E_PARSE => Logger_Interface::LEVEL_ERROR, |
| 232 | + E_STRICT => Logger_Interface::LEVEL_ERROR, | |
| 249 | 233 | |
| 250 | 234 | E_WARNING => Logger_Interface::LEVEL_WARNING, |
| 251 | 235 | E_USER_WARNING => Logger_Interface::LEVEL_WARNING, |
| 252 | 236 | E_CORE_WARNING => Logger_Interface::LEVEL_WARNING, |