[BUGFIX] PHP 5.4 warning in CLI context in switch back user
authorChristian Kuhn <lolli@schwarzbu.ch>
Thu, 1 Nov 2012 22:15:48 +0000 (23:15 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 1 Nov 2012 22:25:27 +0000 (23:25 +0100)
PHP 5.4 raises warnings of type "Illegal string offset" if you access
$foo['bar'] and $foo is no array. This is the case in hook
SwitchBackUser, if in cli context.

Change-Id: I5ed32e054b156c9fbc64e99ff33ba5c4637ce266
Fixes: #37578
Releases: 6.0, 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/16111
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/beuser/class.tx_beuser_switchbackuser.php

index 00e95f6..6554d88 100644 (file)
  */
 class tx_beuser_switchbackuser {
        function switchBack($params, $that)     {
-               if($that->session_table == 'be_sessions' && $that->user['uid'] && $that->user['ses_backuserid']) {
+               if (
+                       $that->session_table == 'be_sessions'
+                       && is_array($that->user)
+                       && $that->user['uid']
+                       && $that->user['ses_backuserid']
+               ) {
                        $updateData = array(
                                'ses_userid' => $that->user['ses_backuserid'],
                                'ses_backuserid' => 0