[TYPO3-mvc] Repository-Query with sys_category ignores category_mm[tablenames] field
Torsten Schrade
schradt at uni-mainz.de
Wed Jan 15 10:58:52 CET 2014
Hi Daniel,
> 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
>
> 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.
You've spotted the correct reason. Unfortunately, the extbase ORM
doesn't support storing relations to multiple tables in one MM table
differentiated by a tablenames field though this is a core
functionality of sys_category. Please see this thread and the ticket on
forge for more details:
-
http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/2013-September/014338.html
- http://forge.typo3.org/issues/39256
It's quite complicated and it doesn't look like this will be in extbase
any time soon, the patch we worked upon had to be abandoned. What can
you do? In my case (since i only needed to read and not to write MM
relations) I solved the problem by overriding the standard
Typo3DBBackend functions with my own functions. See the gist right here:
https://gist.github.com/tesselation/8433623
Place the file in Classes/Persistence/Generic/Storage/ of your
extension and register it with the following TypoScript
config.tx_extbase {
objects {
TYPO3\CMS\Extbase\Persistence\Generic\Storage\BackendInterface {
className =
VENDOR\Extension\Persistence\Generic\Storage\PatchedTypo3DbBackend
}
}
}
That should fix it. Good luck and best regards,
Torsten
More information about the TYPO3-project-typo3v4mvc
mailing list