[TYPO3-mvc] Repository-Query with sys_category ignores category_mm[tablenames] field

Daniel Hirth hirth at stimme.net
Tue Jan 14 16:59:08 CET 2014


Hi there,

i am currently stuck at a strange problem that i just can't solve: 

I am building an extension with different models (event, venue, gallery...), all of which have n:M relations to the sys_category model via the makeCategorizable method. This works all well, except when, in the repository method for any of the models, i try to do a query like this: 

public function getEventsByCategory ($category) {
		$query = $this->createQuery();
		$query->matching($query->contains('categories', $category));
		return $query->execute();
 }

In this simplistic case i just want the events for the given category, but the result of the query often contains Elements that don't have this category attached. 

After a lot of testing, it seems to me that the root of this problem is that i have more than one model using sys_categories. Because the Query seems to ignore the value of the "tablenames" field when fetching the uids for the given category in the category_mm table. Instead it gets all foreign uids for the given category regardless of the tablename value (which - in my case - could be locations instead of events), and then tries to find the events for the given uids, even if the uids originally are for the location-model. Which leads to wrong results in all of my queries. 

I don't know how to fix this, I don't know if I am doing something wrong with my extension settings or if this is some weird core bug. I just know that like this, my extension will be completely useless. 

I tested this with TYPO3 versions 6.1.5 and 6.1.7 with no differences in the described behaviour whatsoever. 

If someone has an idea how to solve this, it would really help a lot. Thanks. 


More information about the TYPO3-project-typo3v4mvc mailing list