[TYPO3-mvc] Changing adding/removing an object to an ObjectStorage removes all hidden records
Steffen Ritter
info at rs-websystems.de
Fri Aug 13 13:33:33 CEST 2010
Am 13.08.2010 12:32, schrieb Steffen Ritter:
> Am 13.08.2010 11:03, schrieb Steffen Ritter:
>
>> I assume this is because on "retrieving object" they are not loaded, on
>> persistence they therefore are not in then object storage - for extbase
>> "anymore" --> the relation gets deleted.
>
> Update: Tx_Extbase_Persistence_Backend::persistObjectStorage() for
> mm-Relations works like
> $this->deleteAllRelationsFromRelationtable($parentObject, $propertyName);
>
> and afterwards adding all which are currently in the storage again.
>
> This is
> a, overhead
> b, not correct
>
>
> Furthermore this "re-sorts" the $objectStorage on every persist...
>
> The behaviour of this function seems to be really weird.
>
> regards
>
> Steffen
>
Attached patch solves the issue, my solution explained.
I deleted "deleteAllRelationsFrom RelationTable". This is valid because
the first loop iterates over all "deleted" relations (compares clean
objectStorage Property to Current One). There
"detachObjectFromParentObject" is called... Inside this function there
is a call to "deleteRelationFromRelationtable" --> the relation is
deleted if neccessary.
I added the same test as for deleted objects for "added" objects:
getCleanProperty and just newly attach the added objects to the parent.
Since there is a call to insertRealtionToRelationTable inside
"attachObjectToParentObject" missing the check would reinsert ALL
relations in the relation table (that's why an "delete all" before has
been introduced).
Therefore this handles adding and removing correctly without "overhead"
of deleting and reinserting all records in relationtable.
regards
Steffen
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: StorageBackend.diff
URL: <http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/attachments/20100813/ea4b8406/attachment.asc>
More information about the TYPO3-project-typo3v4mvc
mailing list