[TYPO3-dev] Symmetric bidirectional MM ralations on the same table

Dmitry Dulepov dmitry.dulepov at gmail.com
Fri Feb 25 09:15:48 CET 2011


Hi!

Stefano Cecere wrote:
> anybody knows how it is solved with FLOW3/Doctrine2 ?

The problem with bidirectional relations is inside t3lib_loaddbgroup and 
only there.

The proposed solution of using a hook to add another record to MM table is 
incorrect (and it does not work well, I tried – it causes various side 
effects and data corruption for MM relations).

Normally you have uid_local and uid_foreign. Assuming you have [3,5] there, 
adding [5,3] is not a good idea because it doubles the size of the table 
and slows down the whole thing. MM relations are slow because they use 
joins and doubling the size of the table makes it even slower. Instead 
t3lib_loaddbgroup should check if the relation is to the same table and use 
a special condition to fetch the data. Something like:

(uid_local=3 and uid_foreign=5) or (uid_foreign=3 and uid_local=5)

It sounds easy to implement but in fact it is not because of the way 
t3lib_loaddbgroup is coded. It needs a serious rewrite to support 
bidirectional MM relations on the same table.

-- 
Dmitry Dulepov
TYPO3 core&security team member
E-mail: dmitry.dulepov at typo3.org
Web: http://dmitry-dulepov.com/




More information about the TYPO3-dev mailing list