From 263e8872eaa828246b248905d393a6befec1d556 Mon Sep 17 00:00:00 2001 From: triatic <42704418+triatic@users.noreply.github.com> Date: Mon, 26 Nov 2018 17:33:51 +0000 Subject: [PATCH] core: Don't use server variables in CLI mode (#939) --- index.php | 6 ++++-- lib/Exceptions.php | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 772f4942..9fb8f2a9 100644 --- a/index.php +++ b/index.php @@ -260,7 +260,8 @@ try { $item['title'] = 'Bridge returned error ' . $e->getCode() . '! (' . $params['_error_time'] . ')'; } - $item['uri'] = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) . '?' . http_build_query($params); + $item['uri'] = (isset($_SERVER['REQUEST_URI']) ? parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) : '') + . '?' . http_build_query($params); $item['timestamp'] = time(); $item['content'] = buildBridgeException($e, $bridge); @@ -273,7 +274,8 @@ try { // Create "new" error message every 24 hours $params['_error_time'] = urlencode((int)(time() / 86400)); - $item['uri'] = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) . '?' . http_build_query($params); + $item['uri'] = (isset($_SERVER['REQUEST_URI']) ? parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) : '') + . '?' . http_build_query($params); $item['title'] = 'Bridge returned error ' . $e->getCode() . '! (' . $params['_error_time'] . ')'; $item['timestamp'] = time(); $item['content'] = buildBridgeException($e, $bridge); diff --git a/lib/Exceptions.php b/lib/Exceptions.php index 4250f9f9..ac452d02 100644 --- a/lib/Exceptions.php +++ b/lib/Exceptions.php @@ -77,7 +77,7 @@ function buildBridgeException($e, $bridge){ $body = 'Error message: `' . $e->getMessage() . "`\nQuery string: `" - . $_SERVER['QUERY_STRING'] + . (isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '') . "`\nVersion: `" . Configuration::getVersion() . '`'; @@ -116,7 +116,8 @@ function buildTransformException($e, $bridge){ $body = 'Error message: `' . $e->getMessage() . "`\nQuery string: `" - . $_SERVER['QUERY_STRING'] . '`'; + . (isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '') + . '`'; $link = buildGitHubIssueQuery($title, $body, 'bug report', $bridge->getMaintainer()); $header = buildHeader($e, $bridge);