[BUGFIX] DataHandler::log() must not return NULL 79/30479/3
authorMarkus Klein <klein.t3@mfc-linz.at>
Wed, 28 May 2014 17:38:29 +0000 (19:38 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 3 Jun 2014 21:39:51 +0000 (23:39 +0200)
Ensure the DataHandler::log() function does return integers
in all cases as denoted in the doc header.

Resolves: #59185
Releases: 6.2, 6.1, 6.0
Change-Id: I2a6aa0415b7cc19f10b4a290e43bd20065e6c9e1
Reviewed-on: https://review.typo3.org/30479
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/core/Classes/DataHandling/DataHandler.php

index 3117972..b7f5284 100644 (file)
@@ -7230,25 +7230,26 @@ class DataHandler {
         * @param array $data Array with special information that may go into $details by '%s' marks / sprintf() when the log is shown
         * @param integer $event_pid The page_uid (pid) where the event occurred. Used to select log-content for specific pages.
         * @param string $NEWid NEW id for new records
-        * @return integer Log entry UID
+        * @return integer Log entry UID (0 if no log entry was written or logging is disabled)
         * @todo Define visibility
         */
        public function log($table, $recuid, $action, $recpid, $error, $details, $details_nr = -1, $data = array(), $event_pid = -1, $NEWid = '') {
-               if ($this->enableLogging) {
-                       // Type value for tce_db.php
-                       $type = 1;
-                       if (!$this->storeLogMessages) {
-                               $details = '';
-                       }
-                       if ($error > 0) {
-                               $detailMessage = $details;
-                               if (is_array($data)) {
-                                       $detailMessage = vsprintf($details, $data);
-                               }
-                               $this->errorLog[] = '[' . $type . '.' . $action . '.' . $details_nr . ']: ' . $detailMessage;
+               if (!$this->enableLogging) {
+                       return 0;
+               }
+               // Type value for tce_db.php
+               $type = 1;
+               if (!$this->storeLogMessages) {
+                       $details = '';
+               }
+               if ($error > 0) {
+                       $detailMessage = $details;
+                       if (is_array($data)) {
+                               $detailMessage = vsprintf($details, $data);
                        }
-                       return $this->BE_USER->writelog($type, $action, $error, $details_nr, $details, $data, $table, $recuid, $recpid, $event_pid, $NEWid);
+                       $this->errorLog[] = '[' . $type . '.' . $action . '.' . $details_nr . ']: ' . $detailMessage;
                }
+               return $this->BE_USER->writelog($type, $action, $error, $details_nr, $details, $data, $table, $recuid, $recpid, $event_pid, $NEWid);
        }
 
        /**