From a6c7af152c2812de32a3217b7b2fbb3d4dde43a8 Mon Sep 17 00:00:00 2001 From: Alexis Bezverkhyy Date: Thu, 27 Mar 2014 17:30:17 +0100 Subject: [PATCH] Fixed issue: during vv export, output data was buffered and lead to out of memory errors when exporting large quantities of answers. --- application/controllers/admin/export.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/application/controllers/admin/export.php b/application/controllers/admin/export.php index ba34fda1d90..ee90ceccb42 100644 --- a/application/controllers/admin/export.php +++ b/application/controllers/admin/export.php @@ -701,7 +701,8 @@ public function vvexport() } $result = Yii::app()->db->createCommand($query)->query(); - foreach ( $result->readAll() as $row ) + echo $vvoutput; + foreach ($result as $row) { foreach ( $fieldnames as $field ) { @@ -743,14 +744,14 @@ public function vvexport() $sun[]=$value; } - $beach = implode($s, $sun); - $vvoutput .= $beach; + /* it is important here to stream output data, line by line + * in order to avoid huge memory consumption when exporting large + * quantities of answers */ + echo implode($s, $sun)."\n"; unset($sun); - $vvoutput .= "\n"; } - echo $vvoutput; exit; } }