[TYPO3-mvc] Bug or feature: implementation of Iterator and ArrayAccess of Tx_Extbase_Persistence_ObjectStorage does't not work as expected

Marc Bastian Heinrichs typo3 at mbh-web.de
Fri Feb 18 10:23:04 CET 2011


Hey,

it's not possible to run via foreach thru an objectStorage object and
detach every element from the objectStorage itself.
The (wrong) result is, that only odd elements get detached and every
even elements will remain in the objectStorage.

Example:

$modelA->modelBs m:m relation to $modelB
$modelBs = $modelA->getModelBs()

So $modelBs is an objectStorage object.

This does not work:
foreach($modelBs as $modelB) {
    $modelBs->detach($modelB);
}

With cloning $modelBs it does work:
$modelBsClone = clone $modelBs;
foreach($modelBsClone as $modelB) {
    $modelBs->detach($modelB);
}

Is this a bug or feature?

Best
Marc Bastian



More information about the TYPO3-project-typo3v4mvc mailing list