PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / 2.7.2
Search Atlas SEO – OTTO AI SEO Automation for WordPress v2.7.2
2.7.1 2.7.2 2.7.0 2.6.26 2.6.25 2.6.24 2.6.23 2.6.22 2.6.21 2.6.20 2.6.19 2.6.18 2.6.17 2.6.16 2.6.15 2.6.14 2.6.13 2.6.12 2.6.11 2.6.10 2.6.9 2.6.8 2.6.7 2.6.6 2.6.5 All 141 releases
← All changes | wp-mcp-server/class-mcp-json-rpc-handler.php +19 -3 2.6.21 → 2.7.2 View file →
@@ -54,9 +54,9 @@
54 54 * @param callable $callback Handler callback
55 55 */
56 56 public function register_handler($method, $callback) {
57 57 if (!is_callable($callback)) {
58 - throw new InvalidArgumentException("Handler for method '{$method}' must be callable");
58 + throw new InvalidArgumentException("Handler for method '{$method}' must be callable"); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- JSON-RPC error payload, JSON-encoded on output, never rendered as HTML; escaping here would corrupt message bytes
59 59 }
60 60 $this->handlers[$method] = $callback;
61 61 }
62 62
@@ -63,9 +63,9 @@
63 63 /**
64 64 * Handle incoming JSON-RPC request
65 65 *
66 66 * @param string $request_body Raw request body
67 - * @return array Response array
67 + * @return array|null Response array, or null for a notification
68 68 */
69 69 public function handle_request($request_body) {
70 70 // Parse JSON
71 71 $request = json_decode($request_body, true);
@@ -88,8 +88,12 @@
88 88 $id = isset($request['id']) ? $request['id'] : null;
89 89
90 90 // Check if handler exists
91 91 if (!isset($this->handlers[$method])) {
92 + if (!array_key_exists('id', $request)) {
93 + return null;
94 + }
95 +
92 96 return $this->error_response($id, self::ERROR_METHOD_NOT_FOUND, "Method not found: {$method}");
93 97 }
94 98
95 99 try {
@@ -94,14 +98,26 @@
94 98
95 99 try {
96 100 // Call handler
97 101 $result = call_user_func($this->handlers[$method], $params);
102 + if (!array_key_exists('id', $request)) {
103 + return null;
104 + }
105 +
98 106 return $this->success_response($id, $result);
99 107 } catch (InvalidArgumentException $e) {
108 + if (!array_key_exists('id', $request)) {
109 + return null;
110 + }
111 +
100 112 return $this->error_response($id, self::ERROR_INVALID_PARAMS, $e->getMessage());
101 113 } catch (Exception $e) {
102 114 // Log error
103 - error_log('MCP JSON-RPC Error: ' . $e->getMessage());
115 + error_log('MCP JSON-RPC Error: ' . $e->getMessage()); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- genuine failure path, bounded, no secrets
116 + if (!array_key_exists('id', $request)) {
117 + return null;
118 + }
119 +
104 120 return $this->error_response($id, self::ERROR_INTERNAL_ERROR, $e->getMessage());
105 121 }
106 122 }
107 123