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

Helmut Hummel helmut.hummel at typo3.org
Fri Feb 25 09:44:16 CET 2011


Hi,

On 25.02.11 09:15, Dmitry Dulepov wrote:

> Stefano Cecere wrote:

> 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).

My proposal was not meant as a final solution, but as a workaround until
TYPO3 can handle such relations correctly. Not as a solution for TYPO3
in general but for your current project, if you need it (I never did).

Can you tell us what exactly will be corrupted when doing which actions?
I can imagine that it would be neccessary to update the reference index
in the hook, anything else?

> 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. 

Will there be a performance impact or data corruption? The first would
be bearable in most situations, the latter not.

> 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)

Yes of course.

> 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.

That's the problem.
"Not easy" == "no one does it" == "customer not happy" ;)


Kind regards,
Helmut

-- 
Helmut Hummel
TYPO3 Security Team Leader

TYPO3 .... inspiring people to share!
Get involved: typo3.org




More information about the TYPO3-dev mailing list