[TYPO3-mvc] findOneBy memory usage

Saverio Vigni s.vigni at hor-net.com
Wed Jul 18 19:09:49 CEST 2012


Oh ok, but it seems counter intuitive, if i'm not mistaken there isn't 
written anywhere that the countBy* works only for persisted objects...

Saverio

Il 18/07/12 19.01, Bastian Waidelich ha scritto:
> Saverio Vigni wrote:
>
> Hi,
>
>> Ok using countByUrl the memory stays low
>
> That's good news.
>
> , the problem i've found is that
>> this method pass the count straight to the persistence backend not
>> taking into account objects that has been added during the execution
>
>
> Yes, that's what I meant with the last paragraph.
>
>> instead of creating a temporary storage in my controller for those
>> objects, i think i'll extend the persistence manager class replacing
>> getObjectCountByQuery and scanning the result of
>> $repository->getAddedObjects() summing then the 2 results.
>
> You can do this, but t seems like an overkill to me to be honest.
>
> $processedUrls = array();
> $url = $link->getUrl();
> if (!in_array($url, $processedUrls) && 
> $this->pageRepository->countByUrl($url)) === 0) {
>     $newPage = 
> $this->objectManager->create('Tx_Webspider_Domain_Model_Page');
>     $newPage->setUrl($url);
>     $this->pageRepository->add($newPage);
>     $processedUrls[] = $url;
> }
>
> should do the trick.
>
>
>> Is it ok if after i've done i fill a bug on extbase forge and provide a
>> patch?
>
> It's not really a bug. You can't use the findBy* methods() either for 
> objects that are not yet persisted.
>




More information about the TYPO3-project-typo3v4mvc mailing list