Revision: 429
http://gemstracker.svn.sourceforge.net/gemstracker/?rev=429&view=rev
Author: mennodekker
Date: 2012-01-30 09:13:30 +0000 (Mon, 30 Jan 2012)
Log Message:
-----------
Fix for big batches running out of memory during initialization: load one row at a time and only include the gto_id_token we need and skip the rest
Modified Paths:
--------------
branches/1.5.x/library/classes/Gems/Tracker.php
Modified: branches/1.5.x/library/classes/Gems/Tracker.php
===================================================================
--- branches/1.5.x/library/classes/Gems/Tracker.php 2012-01-27 15:28:44 UTC (rev 428)
+++ branches/1.5.x/library/classes/Gems/Tracker.php 2012-01-30 09:13:30 UTC (rev 429)
@@ -842,9 +842,9 @@
$batch = $this->_loadClass('Batch_ProcessTokensBatch', true, array($batch_id));
if (! $batch->isLoaded()) {
- $tokenRows = $tokenSelect->fetchAll();
-
- foreach ($tokenRows as $tokenData) {
+ $statement = $tokenSelect->getSelect()->query();
+ //Process one row at a time to prevent out of memory errors for really big resultsets
+ while ($tokenData = $statement->fetch()) {
$batch->addToken($tokenData['gto_id_token'], $userId);
}
}
@@ -898,16 +898,16 @@
public function recalculateTokensBatch($batch_id, $userId = null, $cond = null)
{
$userId = $this->_checkUserId($userId);
- $tokenSelect = $this->getTokenSelect();
- $tokenSelect->andReceptionCodes()
- ->andRespondents()
- ->andRespondentOrganizations()
- ->andConsents();
+ $tokenSelect = $this->getTokenSelect(array('gto_id_token'));
+ $tokenSelect->andReceptionCodes(array())
+ ->andRespondents(array())
+ ->andRespondentOrganizations(array())
+ ->andConsents(array());
if ($cond) {
$tokenSelect->forWhere($cond);
}
//Only select surveys that are active in the source (so we can recalculate inactive in Gems)
- $tokenSelect->andSurveys();
+ $tokenSelect->andSurveys(array());
$tokenSelect->forWhere('gsu_surveyor_active = 1');
self::$verbose = true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|