Skip to content

Commit

Permalink
Fixed #7954: Out of memory error on token export
Browse files Browse the repository at this point in the history
  • Loading branch information
mennodekker committed Jun 26, 2013
1 parent 00612ef commit e129adc
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions application/helpers/export_helper.php
Expand Up @@ -1705,14 +1705,13 @@ function tokensExport($iSurveyID)
$bquery .= " ORDER BY tid";
Yii::app()->loadHelper('database');

$bresult = Yii::app()->db->createCommand($bquery)->query()->readAll(); //dbExecuteAssoc($bquery) is faster but deprecated!
$bresult = Yii::app()->db->createCommand($bquery)->query(); //dbExecuteAssoc($bquery) is faster but deprecated!
//HEADERS should be after the above query else timeout errors in case there are lots of tokens!
header("Content-Disposition: attachment; filename=tokens_".$iSurveyID.".csv");
header("Content-type: text/comma-separated-values; charset=UTF-8");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache");

$bfieldcount=count($bresult);
// Export UTF8 WITH BOM
$tokenoutput = chr(hexdec('EF')).chr(hexdec('BB')).chr(hexdec('BF'));
$tokenoutput .= "tid,firstname,lastname,email,emailstatus,token,language,validfrom,validuntil,invited,reminded,remindercount,completed,usesleft";
Expand All @@ -1731,7 +1730,7 @@ function tokensExport($iSurveyID)
// Export token line by line and fill $aExportedTokens with token exported
Yii::import('application.libraries.Date_Time_Converter', true);
$aExportedTokens = array();
foreach($bresult as $brow)
while ($brow = $bresult->read())
{
if (trim($brow['validfrom']!=''))
{
Expand Down

0 comments on commit e129adc

Please sign in to comment.