[TYPO3-dam] mmforeign causes troubles...
Ernesto Baschny [cron IT]
ernst at cron-it.de
Wed Apr 19 20:33:41 CEST 2006
Franz Koch schrieb am 19.04.2006 01:25:
>> it's a little bit harder then I thought to see the problem. Steps to
>> make it visible:
>> - create a tt_news record with exactly one category selected. Don't
>> choose the category with uid=1.
>> - save the tt_news record (even without closing it)
>> The list of categories now contains 2 items: the one you selected and
>> the category with uid=1.
>> This won't occur if the tt_news record has 0 or more then 1 categories.
> (...)
> The problem is not the storing of the records, but the loading as it
> seems. When I store a record with one category applied and reopen it, a
> second category appears - but that second one (uid 1) is not stored in
> the DB-field of the record yet. By storing the record than, in some
> cases a third category got inserted then.
>
> So we have to search the but inside the class "class.ux_t3lib_tcemain.php".
In file ext/mmforeign/class.ux_t3lib_loaddbgroup.php around line 241
there is:
if ($MMtable) { // If MM, then call this function to do that:
// used here to get defVals when set - [tablename]_[id]
if($itemlist) {
$this->readList($itemlist);
This call to $this->readList($itemlist) is not correct, as the
"$itemlist" will be loaded with the content of the original field, which
in MM-relation-fields is always the COUNT of how many related items we
have, and not the comma-separated item-list itself. This means, in case
of one category stored in the MM-relation would mean loading the
category with uid "1" in this field (similary, if you have 2 categories,
the category with uid "2" will be loaded too). Commenting out or
removing this line makes it "behave" again.
Took me some time to find out the bug, but then I also learned some more
stuff about the internals of TYPO3 (and made me wonder if a
"refactoring" is really possible...).
Cheers,
Ernesto
More information about the TYPO3-project-dam
mailing list