[BUGFIX] Log original user ID during backend user switch 44/44244/4
authorZsolt Molnar <zsolt.molnar@arxia.com>
Fri, 23 Oct 2015 13:33:50 +0000 (16:33 +0300)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 29 Oct 2015 21:24:10 +0000 (22:24 +0100)
If a user has currently switched to another user, use the original
user's ID for logging.

Resolves: #17643
Releases: master
Change-Id: I3c3197bf56e38f97f9552df2af376295ab639eae
Reviewed-on: https://review.typo3.org/44244
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Ruud Silvrants <ruudsilvrants@gmail.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php

index e819ade..e57aa07 100644 (file)
@@ -2178,8 +2178,13 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
      */
     public function writelog($type, $action, $error, $details_nr, $details, $data, $tablename = '', $recuid = '', $recpid = '', $event_pid = -1, $NEWid = '', $userId = 0)
     {
-        if (!$userId && isset($this->user['uid'])) {
-            $userId = $this->user['uid'];
+        if (!$userId) {
+            // Use the original user's ID in case of a user switch
+            if (!empty($this->user['ses_backuserid'])) {
+                $userId = $this->user['ses_backuserid'];
+            } elseif (!empty($this->user['uid'])) {
+                $userId = $this->user['uid'];
+            }
         }
 
         $fields_values = array(