[BUGFIX] PHP 5.4 warning in CLI context in switch back user
authorChristian Kuhn <lolli@schwarzbu.ch>
Thu, 1 Nov 2012 21:24:02 +0000 (22:24 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 1 Nov 2012 21:45:12 +0000 (22:45 +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.

Furthermore, the class is cleaned up a bit in 6.0 version and the
compatibility layer is removed, since the hook file was moved around
together with the beuser refactoring anyway.

Change-Id: I5ed32e054b156c9fbc64e99ff33ba5c4637ce266
Fixes: #37578
Releases: 6.0, 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/16108
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/beuser/Classes/Hook/SwitchBackUserHook.php
typo3/sysext/beuser/Classes/class.tx_beuser_switchbackuser.php [deleted file]
typo3/sysext/beuser/ext_autoload.php [deleted file]
typo3/sysext/core/Migrations/Code/LegacyClassesForIde.php

index 1a50439..f128c74 100644 (file)
@@ -23,8 +23,10 @@ namespace TYPO3\CMS\Beuser\Hook;
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
 /**
- * Backend user switchback, for logoff_pre_processing hook within t3lib_userauth class
+ * Backend user switchback, for logoff_pre_processing hook within
+ * \TYPO3\CMS\Core\Authentication\AbstractUserAuthentication class
  *
  * @author Kasper Skårhøj (kasperYYYY@typo3.com)
  * @author Sebastian Kurfürst <sebastian@garbage-group.de>
@@ -33,24 +35,34 @@ namespace TYPO3\CMS\Beuser\Hook;
 class SwitchBackUserHook {
 
        /**
-        * Switch backen user session
+        * Switch backend user session
         *
         * @param array $params
         * @param \TYPO3\CMS\Core\Authentication\AbstractUserAuthentication $that
-        * @see t3lib_userauth::logoff()
-        * @todo Define visibility
+        * @see \TYPO3\CMS\Core\Authentication\AbstractUserAuthentication
         */
        public function switchBack($params, $that) {
                // Is a backend session handled?
-               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']
+               ) {
                        return;
                }
+
                // @TODO: Move update functionality to Tx_Beuser_Domain_Repository_BackendUserSessionRepository
                $updateData = array(
                        'ses_userid' => $that->user['ses_backuserid'],
                        'ses_backuserid' => 0
                );
-               $GLOBALS['TYPO3_DB']->exec_UPDATEquery('be_sessions', 'ses_id = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->id, 'be_sessions') . ' AND ses_name = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::getCookieName(), 'be_sessions') . ' AND ses_userid=' . intval($GLOBALS['BE_USER']->user['uid']), $updateData);
+               $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
+                       'be_sessions',
+                       'ses_id = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr($GLOBALS['BE_USER']->id, 'be_sessions') .
+                               ' AND ses_name = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr(\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::getCookieName(), 'be_sessions') .
+                               ' AND ses_userid=' . intval($GLOBALS['BE_USER']->user['uid']), $updateData);
+
                $redirectUrl = $GLOBALS['BACK_PATH'] . 'index.php' . ($GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces'] ? '' : '?commandLI=1');
                \TYPO3\CMS\Core\Utility\HttpUtility::redirect($redirectUrl);
        }
diff --git a/typo3/sysext/beuser/Classes/class.tx_beuser_switchbackuser.php b/typo3/sysext/beuser/Classes/class.tx_beuser_switchbackuser.php
deleted file mode 100755 (executable)
index 1ed4df4..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/*
- * @deprecated since 6.0, the classname tx_beuser_switchbackuser and this file is obsolete
- * and will be removed by 7.0. The class was renamed and is now located at:
- * typo3/sysext/beuser/Classes/Hook/SwitchBackUserHook.php
- */
-require_once \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('beuser') . 'Classes/Hook/SwitchBackUserHook.php';
-?>
\ No newline at end of file
diff --git a/typo3/sysext/beuser/ext_autoload.php b/typo3/sysext/beuser/ext_autoload.php
deleted file mode 100755 (executable)
index bf81e7b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-$extensionPath = \TYPO3\CMS\Core\Extension\ExtensionManager::extPath('beuser');
-return array(
-       'tx_beuser_switchbackuser' => $extensionPath . 'Classes/class.tx_beuser_switchbackuser.php'
-);
-?>
\ No newline at end of file
index f169c85..8356c38 100644 (file)
@@ -739,11 +739,6 @@ class Tx_Beuser_Domain_Repository_BackendUserSessionRepository extends \TYPO3\CM
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class tx_beuser_switchbackuser extends \TYPO3\CMS\Beuser\Hook\SwitchBackUserHook {}
-
-/**
- * @deprecated since 6.0 will be removed in 7.0
- */
 class Tx_Beuser_Service_ModuleDataStorageService extends \TYPO3\CMS\Beuser\Service\ModuleDataStorageService {}
 
 /**