aboutsummaryrefslogtreecommitdiffstats
path: root/src/process-request.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/process-request.php')
-rw-r--r--src/process-request.php18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/process-request.php b/src/process-request.php
index d0af0b5..69e1e58 100644
--- a/src/process-request.php
+++ b/src/process-request.php
@@ -29,13 +29,17 @@ $data = [
];
if (preg_match('/xmlrpc\.php/i', $data['REQUEST_URI']) && $data['REQUEST_METHOD'] === 'POST') {
- $method = XmlRpcMethod::parse($data['BODY']);
- if ($method->name === 'wp.getUsersBlogs') {
- save_credentials($data['REQUEST_TIME'], $data['REMOTE_ADDR'], $method->params[0], $method->params[1]);
- error_log("Trapped XML-RPC request: saved credentials");
-
- header("HTTP/1.1 404 Not Found");
- die();
+ try {
+ $method = XmlRpcMethod::parse($data['BODY']);
+ if ($method && $method->name === 'wp.getUsersBlogs') {
+ save_credentials($data['REQUEST_TIME'], $data['REMOTE_ADDR'], $method->params[0], $method->params[1]);
+ error_log("Trapped XML-RPC request: saved credentials");
+
+ header("HTTP/1.1 404 Not Found");
+ die();
+ }
+ } catch (RuntimeException $e) {
+ error_log("Webtrap: {$e->getMessage()} ({$e->getCode()}), saving request instead.");
}
}