[BUGFIX] Category API does not consider multiple tables
[Packages/TYPO3.CMS.git] / 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;