Skip to content

Commit 0b6387e

Browse files
committed
fixed bug, needed env var "ERRPAGE_JSON_PATH" to make test work
1 parent d104a93 commit 0b6387e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

errpages/httperror.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function isLive() {
100100
define('ERROR_CODE', 1);
101101
define('EXPLANATION', 2);
102102

103-
$errorcodes = json_decode(file_get_contents('./errpages/httperror.json'), true);
103+
$errorcodes = json_decode(file_get_contents(getenv('ERRPAGE_JSON_PATH') . 'httperror.json'), true);
104104

105105
if(@$errorcodes["{$http_status}"]) {
106106
$error_code = $errorcodes["{$http_status}"][ERROR_CODE];

testhttperror.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
// this script is for testing ./errpages/httperror.php, just
33
// change the code below
44
$testcode = 401;
5+
// NOTE: The version of httperror.php that uses a JSON file
6+
// for error code content does not use this. Typically this
7+
// was used only for 404 errors.
8+
$_SERVER['REQUEST_URI'] = '/bad_path/no_resource';
59
// this just proves we can overwrite $_SERVER
610
$_SERVER['HTTPS'] = 'on';
711
$_SERVER['SERVER_PORT'] = 443;
812
// get the code to httperror.php...
913
putenv("REDIRECT_STATUS={$testcode}");
1014
// test!
15+
putenv("ERRPAGE_JSON_PATH=./errpages/");
1116
require_once './errpages/httperror.php';
17+
//require_once './errpages/_test.php';
1218
?>

0 commit comments

Comments
 (0)