aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar triatic <42704418+triatic@users.noreply.github.com> 2018-11-26 17:33:51 +0000
committerGravatar LogMANOriginal <LogMANOriginal@users.noreply.github.com> 2018-11-26 18:33:51 +0100
commit263e8872eaa828246b248905d393a6befec1d556 (patch)
treeebbd3fa41d3a5b6298b06abc955e99372f28ddcc
parent6e9c188a7243c5777c8ddfea44785ce1920a3466 (diff)
downloadrss-bridge-263e8872eaa828246b248905d393a6befec1d556.tar.gz
rss-bridge-263e8872eaa828246b248905d393a6befec1d556.tar.zst
rss-bridge-263e8872eaa828246b248905d393a6befec1d556.zip
core: Don't use server variables in CLI mode (#939)
-rw-r--r--index.php6
-rw-r--r--lib/Exceptions.php5
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);