[BUGFIX] Fixes missing referenced variable when $_GET['serendipity'] is not an array

refs #642
refs #653
This commit is contained in:
Garvin Hicking 2019-10-15 14:03:34 +02:00 committed by Thomas Hochstein
parent 4a8616214f
commit 2ea886396b

View File

@ -373,24 +373,28 @@ if (ini_get('magic_quotes_gpc')) {
}
// Merge get and post into the serendipity array
if (array_key_exists('serendipity', $_GET) && is_array($_GET['serendipity'])) {
$serendipity['GET'] = &$_GET['serendipity'];
} else {
$serendipity['GET'] = array();
// It is vital that also an empty array is mapped as a reference
// because the s9y core actually sets new array key values sometimes in $_GET and
// sometimes in $serendipity['GET'] (and POST/COOKIE).
// TODO: This is being worked on currently to be unified see #650
if (!array_key_exists('serendipity', $_GET) || !is_array($_GET['serendipity'])) {
$_GET['serendipity'] = array();
}
if (array_key_exists('serendipity', $_POST) && is_array($_POST['serendipity'])) {
$serendipity['POST'] = &$_POST['serendipity'];
} else {
$serendipity['POST'] = array();
$serendipity['GET'] = &$_GET['serendipity'];
if (!array_key_exists('serendipity', $_POST) || !is_array($_POST['serendipity'])) {
$_POST['serendipity'] = array();
}
if (array_key_exists('serendipity', $_COOKIE) && is_array($_COOKIE['serendipity'])) {
$serendipity['COOKIE'] = &$_COOKIE['serendipity'];
} else {
$serendipity['COOKIE'] = array();
$serendipity['POST'] = &$_POST['serendipity'];
if (!array_key_exists('serendipity', $_COOKIE) || !is_array($_COOKIE['serendipity'])) {
$_COOKIE['serendipity'] = array();
}
$serendipity['COOKIE'] = &$_COOKIE['serendipity'];
// Attempt to fix IIS compatibility
if (empty($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . '?' . (!empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '');