Fixed bug #14023: choose proper variable namings in tslib_cObj::getGlobal()
authorDmitry Dulepov <dmitry.dulepov@gmail.com>
Tue, 13 Apr 2010 09:18:54 +0000 (09:18 +0000)
committerDmitry Dulepov <dmitry.dulepov@gmail.com>
Tue, 13 Apr 2010 09:18:54 +0000 (09:18 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7336 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/tslib/class.tslib_content.php

index 0082280..901690b 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2010-04-13  Dmitry Dulepov <dmitry.dulepov@gmail.com>
 
        * Fixed bug #14027: Tweak: Add "tiff" to imagefile_ext array
+       * Fixed bug #14023: choose proper variable namings in tslib_cObj::getGlobal()
 
 2010-04-13  Patrick Broens  <patrick@patrickbroens.nl>
 
index 464884b..1c049cb 100644 (file)
@@ -5715,33 +5715,30 @@ class tslib_cObj {
         * @param       string          Global var key, eg. "HTTP_GET_VAR" or "HTTP_GET_VARS|id" to get the GET parameter "id" back.
         * @param       array           Alternative array than $GLOBAL to get variables from.
         * @return      mixed           Whatever value. If none, then blank string.
-        * @access private
         * @see getData()
         */
-       function getGlobal($var, $source=NULL)  {
-               $vars = explode('|', $var);
-               $c = count($vars);
-               $k = trim($vars[0]);
-               $theVar = isset($source) ? $source[$k] : $GLOBALS[$k];
-
-               for ($a=1;$a<$c;$a++)   {
-                       if (!isset($theVar))    { break; }
-
-                       $key = trim($vars[$a]);
-                       if (is_object($theVar)) {
-                               $theVar = $theVar->$key;
-                       } elseif (is_array($theVar))    {
-                               $theVar = $theVar[$key];
+       function getGlobal($keyString, $source = NULL) {
+               $keys = explode('|', $keyString);
+               $numberOfLevels = count($keys);
+               $rootKey = trim($keys[0]);
+               $value = isset($source) ? $source[$rootKey] : $GLOBALS[$rootKey];
+
+               for ($i = 1; $i < $numberOfLevels && isset($value); $i++) {
+                       $currentKey = trim($keys[$i]);
+                       if (is_object($value)) {
+                               $value = $value->$currentKey;
+                       } elseif (is_array($value)) {
+                               $value = $value[$currentKey];
                        } else {
-                               return '';
+                               $value = '';
+                               break;
                        }
                }
 
-               if (!is_array($theVar) && !is_object($theVar))  {
-                       return $theVar;
-               } else {
-                       return '';
+               if (!is_scalar($value)) {
+                       $value = '';
                }
+               return $value;
        }
 
        /**