[TYPO3-mvc] Calling persistAll() inside a loop

Martin Kutschker masi-no at spam-typo3.org
Thu Dec 30 20:17:08 CET 2010


Am 30.12.2010 00:12, schrieb Franz Koch:
> Hey,
> 
>>> So i tried to call persistAll() after i added the category to the repository which leads me to two
>>> problems:
>>>
>>> - First, the performance isn't very nice.
>>> - Second, it seems that my fe_users are persisted more than one time
>>
>> I think you can persist single object, no need to persist everything.
> 
> AFAIK there is no API method for this, nor is there a public method you could call by hand messing
> with the PersistenceBackend.

Really? I thought there was.

>> Anyway, your problem shows that the developer must be aware of the magic that is going on. Any query
>> may return stale results if you have altered or added objects to the repository, but didn't persist
>> the changes.
> 
> Even if the categories would be persisted immediately, there wouldn't be any performance boost
> compared to the local category cache.

Right. My point was that an unaware programmer might be lured into the idea that Extbase does
everything for you in a magical way so that you don't have to care. But this is simply not the case.
When you use an API, know it well.

> But I agree that it's a bit odd that the repository doesn't know about newly added objects when
> using it in the same process.

This may be surprising, but a good documentation of the fact is a valid cure.

> It's arguable if a repository->add/update/remove should instantly trigger the persistence - IIRC
> there was a discussion about this already, but I'm not sure.

I don't think that this is really necessary. OTOH I think it might be nice to have a more fine
grained control over persistence.

Masi


More information about the TYPO3-project-typo3v4mvc mailing list