[BUGFIX] Category API does not consider multiple tables 67/22367/2
authorMarc Wöhlken <woehlken@quadracom.de>
Fri, 5 Jul 2013 16:23:58 +0000 (18:23 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 16 Jul 2013 21:08:29 +0000 (23:08 +0200)
Using the Category API with multiple tables, leads to wrong
results due to a missing check for the correct table.

Resolves: #45332
Releases: 6.2, 6.1, 6.0
Change-Id: Iaf5b453acd434ab8d8f58932a2c96385a66abf37
(cherry picked from commit 7c97fe9f6ac712faba8dac4ecf0e2c127038b5d6)
Reviewed-on: https://review.typo3.org/22367
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/core/Classes/Category/Collection/CategoryCollection.php

index 60f44d2..5fe7695 100644 (file)
@@ -101,7 +101,14 @@ class CategoryCollection extends \TYPO3\CMS\Core\Collection\AbstractRecordCollec
        protected function getCollectedRecords() {
                $relatedRecords = array();
                /** @var $GLOBALS['TYPO3_DB'] \TYPO3\CMS\Core\Database\DatabaseConnection */
-               $resource = $this->getDatabase()->exec_SELECT_mm_query($this->getItemTableName() . '.*', self::$storageTableName, 'sys_category_record_mm', $this->getItemTableName(), 'AND ' . self::$storageTableName . '.uid=' . intval($this->getIdentifier()));
+               $resource = $this->getDatabase()->exec_SELECT_mm_query(
+                       $this->getItemTableName() . '.*',
+                       self::$storageTableName,
+                       'sys_category_record_mm',
+                       $this->getItemTableName(),
+                       'AND ' . self::$storageTableName . '.uid=' . intval($this->getIdentifier())
+                               . ' AND sys_category_record_mm.tablenames = "' . $this->getItemTableName() . '"'
+               );
                if ($resource) {
                        while ($record = $this->getDatabase()->sql_fetch_assoc($resource)) {
                                $relatedRecords[] = $record;
@@ -238,4 +245,4 @@ class CategoryCollection extends \TYPO3\CMS\Core\Collection\AbstractRecordCollec
 }
 
 
-?>
\ No newline at end of file
+?>