[BUGFIX] Better performance of DatabaseConnection->getDateTimeFormats 27/35427/2
authorStephan Großberndt <stephan@grossberndt.de>
Tue, 9 Dec 2014 14:42:19 +0000 (15:42 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 14 Dec 2014 16:37:40 +0000 (17:37 +0100)
Currently each call to DatabaseConnection->getDateTimeFormats creates a
new array with default dateTimeFormats. Put this information into a
static class member and return this instead.

Resolves: #63669
Releases: master, 6.2
Change-Id: I457ad6b68fb6919782f349550e9efd07143d0de7
Reviewed-on: http://review.typo3.org/35427
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/Database/DatabaseConnection.php

index 7814790..7fe5ab5 100644 (file)
@@ -166,6 +166,22 @@ class DatabaseConnection {
 
 
        /**
+        * the date and time formats compatible with the database in general
+        *
+        * @var array
+        */
+       static protected $dateTimeFormats = array(
+               'date' => array(
+                       'empty' => '0000-00-00',
+                       'format' => 'Y-m-d'
+               ),
+               'datetime' => array(
+                       'empty' => '0000-00-00 00:00:00',
+                       'format' => 'Y-m-d H:i:s'
+               )
+       );
+
+       /**
         * Initialize the database connection
         *
         * @return void
@@ -952,16 +968,7 @@ class DatabaseConnection {
         * @return array
         */
        public function getDateTimeFormats($table) {
-               return array(
-                       'date' => array(
-                               'empty' => '0000-00-00',
-                               'format' => 'Y-m-d'
-                       ),
-                       'datetime' => array(
-                               'empty' => '0000-00-00 00:00:00',
-                               'format' => 'Y-m-d H:i:s'
-                       )
-               );
+               return self::$dateTimeFormats;
        }
 
        /**************************************