Fixed bug #12800: Add functionality to work with caching framework and DBAL
authorOliver Hader <oliver.hader@typo3.org>
Sun, 29 Nov 2009 17:18:19 +0000 (17:18 +0000)
committerOliver Hader <oliver.hader@typo3.org>
Sun, 29 Nov 2009 17:18:19 +0000 (17:18 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@6589 709f56b5-9817-0410-a4d7-c38de5d9e867

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

index ba5d8b6..eb5cf23 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,6 +26,7 @@
        * Fixed bug #9766: Use correct memory limit definition in Install Tool (thanks to Steffen Mueller)
        * Fixed bug #12830: Wrong encoding of JSON data in t3lib_PageRenderer
        * Fixed bug #11395: TCAdefaults in Page TSConfig without effect on creating new element after existing one (thanks to Tolleiv Nietsch)
+       * Fixed bug #12800: Add functionality to work with caching framework and DBAL (thanks to Xavier Perseguers)
 
 2009-11-26  Francois Suter  <francois@typo3.org>
 
index 9fcf1cd..c1ab49c 100644 (file)
@@ -292,7 +292,7 @@ class t3lib_cache_backend_DbBackend extends t3lib_cache_backend_AbstractBackend
                $GLOBALS['TYPO3_DB']->exec_DELETEquery(
                        $this->cacheTable,
                        'identifier IN (' .
-                               $GLOBALS['TYPO3_DB']->SELECTquery(
+                               $GLOBALS['TYPO3_DB']->SELECTsubquery(
                                        'identifier',
                                        $this->tagsTable,
                                        $this->getQueryForTag($tag)
@@ -322,7 +322,7 @@ class t3lib_cache_backend_DbBackend extends t3lib_cache_backend_AbstractBackend
                        $GLOBALS['TYPO3_DB']->exec_DELETEquery(
                                $this->cacheTable,
                                'identifier IN (' .
-                                       $GLOBALS['TYPO3_DB']->SELECTquery(
+                                       $GLOBALS['TYPO3_DB']->SELECTsubquery(
                                                'identifier',
                                                $this->tagsTable,
                                                implode(' OR ', $listQueryConditions)
@@ -347,7 +347,7 @@ class t3lib_cache_backend_DbBackend extends t3lib_cache_backend_AbstractBackend
                $GLOBALS['TYPO3_DB']->exec_DELETEquery(
                        $this->tagsTable,
                        'identifier IN (' .
-                               $GLOBALS['TYPO3_DB']->SELECTquery(
+                               $GLOBALS['TYPO3_DB']->SELECTsubquery(
                                        'identifier',
                                        $this->cacheTable,
                                        'crdate + lifetime < ' . $GLOBALS['EXEC_TIME'] . ' AND lifetime > 0'
index 2ad7108..db038d6 100644 (file)
@@ -514,6 +514,29 @@ class t3lib_DB {
        }
 
        /**
+        * Creates a SELECT SQL-statement to be used as subquery within another query.
+        * BEWARE: This method should not be overriden within DBAL to prevent quoting from happening.
+        * 
+        * @param       string          $select_fields: List of fields to select from the table.
+        * @param       string          $from_table: Table from which to select.
+        * @param       string          $where_clause: Conditional WHERE statement
+        * @return      string          Full SQL query for SELECT
+        */
+       public function SELECTsubquery($select_fields, $from_table, $where_clause) {
+                       // Table and fieldnames should be "SQL-injection-safe" when supplied to this function
+                       // Build basic query:
+               $query = 'SELECT ' . $select_fields . ' FROM ' . $from_table .
+                       (strlen($where_clause) > 0 ? ' WHERE ' . $where_clause : '');
+
+                       // Return query:
+               if ($this->debugOutput || $this->store_lastBuiltQuery) {
+                       $this->debug_lastBuiltQuery = $query;
+               }
+
+               return $query;
+       }
+
+       /**
         * Returns a WHERE clause that can find a value ($value) in a list field ($field)
         * For instance a record in the database might contain a list of numbers,
         * "34,234,5" (with no spaces between). This query would be able to select that
index 3c092b8..d5593f3 100644 (file)
@@ -247,6 +247,9 @@ class t3lib_sqlparser {
                        }
                } else return $this->parseError('No table to select from!',$parseString);
 
+                       // Store current parseString in the result array for possible further processing (e.g., subquery support by DBAL)
+               $result['parseString'] = $parseString;
+
                        // Return result:
                return $result;
        }