Performance enhancement in t3lib/class.t3lib_tstemplate.php: use UPDATE/INSERT_on_upd...
authorDmitry Dulepov <dmitry.dulepov@gmail.com>
Tue, 29 Aug 2006 12:24:41 +0000 (12:24 +0000)
committerDmitry Dulepov <dmitry.dulepov@gmail.com>
Tue, 29 Aug 2006 12:24:41 +0000 (12:24 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@1695 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_tstemplate.php

index b43e4dc..a1c4993 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2006-08-29  Dmitry Dulepov  <typo3@accio.lv>
+
+       * Performance enhancement in t3lib/class.t3lib_tstemplate.php: use UPDATE/INSERT_on_update_fail instead of DELETE/INSERT for cache_pagesection.
+
 2006-08-25  Michael Stucki  <michael@typo3.org>
 
        * Fixed bug #4076: Skin creates invalid HTML markup
index 864460e..42345f6 100755 (executable)
@@ -356,15 +356,17 @@ class t3lib_TStemplate    {
                        $GLOBALS['TSFE']->all=$cc;
 
                        if (!$this->simulationHiddenOrTime)     {       // Only save currentPageData, if we're not simulating by hidden/starttime/endtime
-                               $insertFields = array(
-                                       'page_id' => intval($GLOBALS['TSFE']->id),
-                                       'mpvar_hash' => t3lib_div::md5int($GLOBALS['TSFE']->MP),
+                               $dbFields = array(
                                        'content' => serialize($cc),
                                        'tstamp' => $GLOBALS['EXEC_TIME']
                                );
-                               $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pagesection', 'page_id='.intval($GLOBALS['TSFE']->id).' AND mpvar_hash='.t3lib_div::md5int($GLOBALS['TSFE']->MP));
-
-                               $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pagesection', $insertFields);
+                               $mpvar_hash = t3lib_div::md5int($GLOBALS['TSFE']->MP);
+                               $GLOBALS['TYPO3_DB']->exec_UPDATEquery('cache_pagesection', 'page_id=' . intval($GLOBALS['TSFE']->id) . ' AND mpvar_hash=' . $mpvar_hash, $dbFields);
+                               if ($GLOBALS['TYPO3_DB']->sql_affected_rows() == 0) {
+                                       $dbFields['page_id'] = intval($GLOBALS['TSFE']->id);
+                                       $dbFields['mpvar_hash'] = $mpvar_hash;
+                                       $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pagesection', $dbFields);
+                               }
                        }
                                // If everything OK.
                        if ($this->rootId && $this->rootLine && $this->setup)   {