[TYPO3-mvc] Cannot update mm-relation (missing tablenames)

Kevin Ulrich Moschallski km at 3digit.de
Sun Nov 14 23:35:35 CET 2010


Hi Jochen,
Hi list,

i found a view minutes today to dig into the problem again. As far i can see now the problem why the relation is removed after insert like i described in my last post is, that the function deleteAllRelationsFromRelationtable() deletes it. This function is called when the parent object is persisted.

With the patch of Jochen this doesn't happen because, i think, this statement in the function doesn't match the fields:

$relationTableMatchFields = $columnMap->getRelationTableMatchFields();
		if (is_array($relationTableMatchFields) && count($relationTableMatchFields) > 0) {
			$relationMatchFields = array_merge($relationTableMatchFields,$relationMatchFields);
		}

I will continue with work on this but maybe somebody knows more about the tablenames field and MM_match_fields and could help here.

Regards,


Am 14.11.2010 um 00:11 schrieb Kevin Ulrich Moschallski:

> Hi Jochen,
> 
> i applied your patch and the tablenames field is filled with the name of the child table. I'm not quite sure about this because it's not well documented, but as far is i saw in some examples the value for tablenames isn't the child table name. It is the name of the parent table. Please have a look here:
> 
> http://buzz.typo3.org/teams/core/article/bidirection-mm-relations/
> 
> Let me first post my current TCA for better understanding:
> 
> Parent table:
> 
> 'items' => array(
> 			'exclude' => 0,
> 			'label'   => 'LLL:EXT:specialoffers_mvc/Resources/Private/Language/locallang_db.xml:tx_specialoffersmvc_domain_model_portal.items',
> 			'config'  => array(
>                                'type' => 'group',
>                                'internal_type' => 'db',
>                                'allowed' => 'tx_specialoffersmvc_domain_model_item',
>                                'foreign_table' => 'tx_specialoffersmvc_domain_model_item',
>                                'MM_opposite_field' => 'portals',
>                                'MM' => 'tx_specialoffersmvc_portal_item_mm',
>                                'MM_match_fields' => array(
>                                    'tablenames' => 'tx_specialoffersmvc_domain_model_portal'
>                                ),
>                                'size' => 5,
>                                'maxitems' => 9999
> 			)
> 		),
> 
> Child table:
> 
> 'portals' => array(
> 			'exclude' => 0,
> 			'label'   => 'LLL:EXT:specialoffers_mvc/Resources/Private/Language/locallang_db.xml:tx_specialoffersmvc_domain_model_item.portals',
> 			'config'  => array(
>                                'type' => 'group',
>                                'internal_type' => 'db',
>                                'allowed' => 'tx_specialoffersmvc_domain_model_portal',
>                                'MM_match_fields' => array('tablenames' => 'tx_specialoffersmvc_domain_model_portal'),
>                                'foreign_table' => 'tx_specialoffersmvc_domain_model_portal',
>                                'foreign_field' => 'items',
>                                'prepend_tname' => 1,
>                                'size' => 5,
>                                'maxitems' => 9999,
>                                'MM' => 'tx_specialoffersmvc_portal_item_mm',
> 			)
> 		),
> 
> When i now add relations on the backend the value of tablenames is set to tx_specialoffersmvc_domain_model_portal from both sides. When i now add a relation with extbase all my relations are overwritten and the value for tablenames becomes tx_specialoffersmvc_domain_model_item like the code suggest:
> 
> $row[$columnMap->getRelationTableRelatedTableColumnName()] = $columnMap->getChildTableName();
> 
> I tried to get the tablename from MM_match_fields:
> 
> if ($columnMap->getRelationTableRelatedTableColumnName() !== NULL && $columnMap->getChildTableName() !== NULL && array_key_exists($columnMap->getRelationTableRelatedTableColumnName(), $columnMap->getRelationTableMatchFields())) {
>                        $arrayMatchFields = $columnMap->getRelationTableMatchFields();
>                        $row[$columnMap->getRelationTableRelatedTableColumnName()] = $arrayMatchFields[$columnMap->getRelationTableRelatedTableColumnName()];
> 		}
> 
> I can see in my sql log that the relation is inserted correct but after that a delete query removes it.
> 
> Do you have an idea why this happens or maybe you have a better approach.
> 
> It's late now and i will continue tomorrow with this issue, also with increase and decrease the other side of the relation when mm_opposite_field is set.
> 
> Regards,
> 
> Kevin
> Am 13.11.2010 um 23:09 schrieb Jochen Rau:
> 
>> Hi.
>> 
>>> I have opened an Issue and scheduled it for 1.3.0beta2.
>>> 
>>> http://forge.typo3.org/issues/10770
>> 
>> ... and attached a patch. Please test and give feedback.
>> 
>> Regards
>> Jochen
>> _______________________________________________
>> TYPO3-project-typo3v4mvc mailing list
>> TYPO3-project-typo3v4mvc at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
> 
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc



More information about the TYPO3-project-typo3v4mvc mailing list