Follow-up to bug #11903: Use two queries to clean tags for DBAL reasons
authorOliver Hader <oliver.hader@typo3.org>
Thu, 1 Oct 2009 17:40:19 +0000 (17:40 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Thu, 1 Oct 2009 17:40:19 +0000 (17:40 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@6095 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/cache/backend/class.t3lib_cache_backend_dbbackend.php
t3lib/class.t3lib_db.php

index ac0d2c9..6dea01c 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@
        * Raised DBAL version from 0.9.21 to 0.9.22
        * Cleanup: Updated NEWS.txt
        * Follow-up to feature #7461: Fixed bug in using the cookieDomain value (thanks to Xavier Perseguers)
+       * Follow-up to bug #11903: Use two queries to clean tags for DBAL reasons
 
 2009-10-01  Rupert Germann  <rupi@gmx.li>
 
index 90be991..ee546bb 100644 (file)
@@ -289,11 +289,20 @@ class t3lib_cache_backend_DbBackend extends t3lib_cache_backend_AbstractBackend
         * @return void
         */
        public function flushByTag($tag) {
-               $GLOBALS['TYPO3_DB']->exec_DELETEmultipleTablesQuery(
-                       $this->tableList,
-                       $this->tableList,
-                       $this->tableJoin .
-                               ' AND ' . $this->getQueryForTag($tag)
+               $GLOBALS['TYPO3_DB']->exec_DELETEquery(
+                       $this->cacheTable,
+                       'identifier IN (' .
+                               $GLOBALS['TYPO3_DB']->SELECTquery(
+                                       'identifier',
+                                       $this->tagsTable,
+                                       $this->getQueryForTag($tag)
+                               ) .
+                       ')'
+               );
+
+               $GLOBALS['TYPO3_DB']->exec_DELETEquery(
+                       $this->tagsTable,
+                       $this->getQueryForTag($tag)
                );
        }
 
@@ -310,11 +319,20 @@ class t3lib_cache_backend_DbBackend extends t3lib_cache_backend_AbstractBackend
                                $listQueryConditions[$tag] = $this->getQueryForTag($tag);
                        }
        
-                       $GLOBALS['TYPO3_DB']->exec_DELETEmultipleTablesQuery(
-                               $this->tableList,
-                               $this->tableList,
-                               $this->tableJoin .
-                                       ' AND (' . implode(' OR ', $listQueryConditions) . ')'
+                       $GLOBALS['TYPO3_DB']->exec_DELETEquery(
+                               $this->cacheTable,
+                               'identifier IN (' .
+                                       $GLOBALS['TYPO3_DB']->SELECTquery(
+                                               'identifier',
+                                               $this->tagsTable,
+                                               implode(' OR ', $listQueryConditions)
+                                       ) .
+                               ')'
+                       );
+
+                       $GLOBALS['TYPO3_DB']->exec_DELETEquery(
+                               $this->tagsTable,
+                               implode(' OR ', $listQueryConditions)
                        );
                }
        }
@@ -326,12 +344,15 @@ class t3lib_cache_backend_DbBackend extends t3lib_cache_backend_AbstractBackend
         * @author Ingo Renner <ingo@typo3.org>
         */
        public function collectGarbage() {
-               $GLOBALS['TYPO3_DB']->exec_DELETEmultipleTablesQuery(
-                       $this->tableList,
-                       $this->tableList,
-                       $this->tableJoin .
-                               ' AND ' . $this->cacheTable . '.crdate + ' . $this->cacheTable . '.lifetime < ' . $GLOBALS['EXEC_TIME'] .
-                               ' AND ' . $this->cacheTable . '.lifetime > 0'
+               $GLOBALS['TYPO3_DB']->exec_DELETEquery(
+                       $this->tagsTable,
+                       'identifier IN (' .
+                               $GLOBALS['TYPO3_DB']->SELECTquery(
+                                       'identifier',
+                                       $this->cacheTable,
+                                       'crdate + lifetime < ' . $GLOBALS['EXEC_TIME'] . ' AND lifetime > 0'
+                               ) .
+                       ')'
                );
 
                $GLOBALS['TYPO3_DB']->exec_DELETEquery(
index d852101..6308cff 100644 (file)
@@ -216,22 +216,6 @@ class t3lib_DB {
        }
 
        /**
-        * Creates and executes a DELETE SQL-statement for multiple tables.
-        *
-        * @param       string          $tablesToDeleteFrom: Name of the tables to delete from
-        * @param       string          $tablesReference: Name of the tables references join the results
-        * @param       string          $where: WHERE clause, eg. "uid=1". NOTICE: You must escape values in this argument with $this->fullQuoteStr() yourself!
-        * @return      pointer         MySQL result pointer
-        */
-       public function exec_DELETEmultipleTablesQuery($tablesToDeleteFrom, $tablesReference, $where) {
-               $res = mysql_query($this->DELETEmultipleTablesQuery($tablesToDeleteFrom, $tablesReference, $where), $this->link);
-               if ($this->debugOutput) {
-                       $this->debug('exec_DELETEquery');
-               }
-               return $res;
-       }
-
-       /**
         * Creates and executes a SELECT SQL-statement
         * Using this function specifically allow us to handle the LIMIT feature independently of DB.
         * Usage count/core: 340
@@ -482,31 +466,6 @@ class t3lib_DB {
        }
 
        /**
-        * Creates a DELETE SQL-statement for multiple tables
-        * Usage count/core: 3
-        *
-        * @param       string          See exec_DELETEmultipleTablesQuery()
-        * @param       string          See exec_DELETEmultipleTablesQuery()
-        * @param       string          See exec_DELETEmultipleTablesQuery()
-        * @return      string          Full SQL query for DELETE from multiple tables
-        */
-       public function DELETEmultipleTablesQuery($tablesToDeleteFrom, $tablesReference, $where) {
-               if (is_string($where)) {
-                               // Table and fieldnames should be "SQL-injection-safe" when supplied to this function
-                       $query = 'DELETE ' . $tablesToDeleteFrom . ' FROM ' . $tablesReference .
-                               (strlen($where) > 0 ? ' WHERE ' . $where : '');
-
-                       if ($this->debugOutput || $this->store_lastBuiltQuery) {
-                               $this->debug_lastBuiltQuery = $query;
-                       }
-
-                       return $query;
-               } else {
-                       die('<strong>TYPO3 Fatal Error:</strong> "Where" clause argument for DELETE query was not a string in $this->DELETEmultipleTablesQuery() !');
-               }
-       }
-
-       /**
         * Creates a SELECT SQL-statement
         * Usage count/core: 11
         *