[BUGFIX] Fix PHP warning when writing to Backend user log 16/23116/4
authorAlexander Stehlik <alexander.stehlik@googlemail.com>
Thu, 15 Aug 2013 16:05:10 +0000 (18:05 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 19 Sep 2013 20:03:04 +0000 (22:03 +0200)
The writelog method for the BackendUserAuthentication object is now
checking if there is actually an uid available in the user array
before it tries to access it.

This prevents a PHP warning about an illegal string offset when writing
log messages in an authentication service.

Releases: 6.0, 6.1, 6.2
Resolves: #49328
Change-Id: I006c6b0ccd8f03292715a7d7ab8e457914637d93
Reviewed-on: https://review.typo3.org/23116
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php

index 7654da5..11b28a3 100644 (file)
@@ -2055,8 +2055,12 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
         * @todo Define visibility
         */
        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'];
+               }
+
                $fields_values = array(
-                       'userid' => $userId ? $userId : intval($this->user['uid']),
+                       'userid' => intval($userId),
                        'type' => intval($type),
                        'action' => intval($action),
                        'error' => intval($error),
@@ -2392,4 +2396,4 @@ This is a dump of the failures:
 }
 
 
-?>
\ No newline at end of file
+?>