From 4014a41c026e305b5c49cd0be2b2c0671a7260ca Mon Sep 17 00:00:00 2001 From: "monte.ohrt" Date: Mon, 15 Jun 2009 14:04:53 +0000 Subject: [PATCH] update super global access to gracefully handle unset super global vars --- libs/Smarty.class.php | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index a1aefb75..5254b241 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -579,16 +579,27 @@ class Smarty $this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']); - $this->_supers['get'] = $this->request_use_auto_globals ? $_GET : $GLOBALS['HTTP_GET_VARS']; - $this->_supers['post'] = $this->request_use_auto_globals ? $_POST : $GLOBALS['HTTP_POST_VARS']; - $this->_supers['server'] = $this->request_use_auto_globals ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; - if(isset($_SESSION)) - $this->_supers['session'] = $this->request_use_auto_globals ? $_SESSION : $GLOBALS['HTTP_SESSION_VARS']; - else - $this->_supers['session'] = array(); - $this->_supers['request'] = $this->request_use_auto_globals ? $_REQUEST : $GLOBALS['HTTP_REQUEST_VARS']; - $this->_supers['cookies'] = $this->request_use_auto_globals ? $_COOKIE : $GLOBALS['HTTP_COOKIE_VARS']; - $this->_supers['env'] = $this->request_use_auto_globals ? $_ENV : $GLOBALS['HTTP_ENV_VARS']; + $this->_supers['get'] = $this->request_use_auto_globals + ? (isset($_GET) ? $_GET : array()) + : $GLOBALS['HTTP_GET_VARS']; + $this->_supers['post'] = $this->request_use_auto_globals + ? (isset($_POST) ? $_POST : array()) + : $GLOBALS['HTTP_POST_VARS']; + $this->_supers['server'] = $this->request_use_auto_globals + ? (isset($_SERVER) ? $_SERVER : array()) + : $GLOBALS['HTTP_SERVER_VARS']; + $this->_supers['session'] = $this->request_use_auto_globals + ? (isset($_SESSION) ? $_SESSION : array()) + : $GLOBALS['HTTP_SESSION_VARS']; + $this->_supers['request'] = $this->request_use_auto_globals + ? (isset($_REQUEST) ? $_REQUEST : array()) + : $GLOBALS['HTTP_REQUEST_VARS']; + $this->_supers['cookies'] = $this->request_use_auto_globals + ? (isset($_COOKIE) ? $_COOKIE : array()) + : $GLOBALS['HTTP_COOKIE_VARS']; + $this->_supers['env'] = $this->request_use_auto_globals + ? (isset($_ENV) ? $_ENV : array()) + : $GLOBALS['HTTP_ENV_VARS']; }