[TYPO3-mvc] findOneBy memory usage

Bastian Waidelich bastian at typo3.org
Wed Jul 18 19:01:12 CEST 2012


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.

-- 
Bastian Waidelich
TYPO3 Core Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org




More information about the TYPO3-project-typo3v4mvc mailing list