[BUGFIX] Category API does not consider multiple tables 63/21963/3
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 20:57:37 +0000 (22:57 +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
Reviewed-on: https://review.typo3.org/21963
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/core/Classes/Category/Collection/CategoryCollection.php

index 2bfe1a0..3e16daa 100644 (file)
@@ -100,7 +100,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;