From f3e245c60a4bd8156adc103970d64e76efd275fa Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Fri, 19 Sep 2014 18:19:02 +0200 Subject: [PATCH] Fixed issue: High memory usage on db upgrade from older versions --- application/helpers/update/updatedb_helper.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/application/helpers/update/updatedb_helper.php b/application/helpers/update/updatedb_helper.php index b4bcf1f7617..d2c84486282 100644 --- a/application/helpers/update/updatedb_helper.php +++ b/application/helpers/update/updatedb_helper.php @@ -1282,21 +1282,24 @@ function upgradeSurveys177() { $sSurveyQuery = "SELECT surveyls_attributecaptions,surveyls_survey_id,surveyls_language FROM {{surveys_languagesettings}}"; $oSurveyResult = Yii::app()->db->createCommand($sSurveyQuery)->queryAll(); - $sSurveyLSUpdateQuery= "update {{surveys_languagesettings}} set surveyls_attributecaptions=:attributecaptions where surveyls_survey_id=".$aSurveyRow['surveyls_survey_id'].' and surveyls_language=:language'; + $sSurveyLSUpdateQuery= "update {{surveys_languagesettings}} set surveyls_attributecaptions=:attributecaptions where surveyls_survey_id=:surveyid and surveyls_language=:language"; foreach ( $oSurveyResult as $aSurveyRow ) { $aAttributeDescriptions=@unserialize($aSurveyRow['surveyls_attributecaptions']); if (!$aAttributeDescriptions) $aAttributeDescriptions=array(); - Yii::app()->db->createCommand($sSurveyLSUpdateQuery)->execute(array(':language'=>$aSurveyRow['surveyls_language'],':attributecaptions'=>json_encode($aAttributeDescriptions))); + Yii::app()->db->createCommand($sSurveyLSUpdateQuery)->execute( + array(':language'=>$aSurveyRow['surveyls_language'], + ':surveyid'=>$aSurveyRow['surveyls_survey_id'], + ':attributecaptions'=>json_encode($aAttributeDescriptions))); } $sSurveyQuery = "SELECT sid FROM {{surveys}}"; $oSurveyResult = Yii::app()->db->createCommand($sSurveyQuery)->queryAll(); - $sSurveyUpdateQuery= "update {{surveys}} set attributedescriptions=:attributedescriptions where sid=".$aSurveyRow['sid']; + $sSurveyUpdateQuery= "update {{surveys}} set attributedescriptions=:attributedescriptions where sid=:surveyid"; foreach ( $oSurveyResult as $aSurveyRow ) { $aAttributeDescriptions=@unserialize($aSurveyRow['attributedescriptions']); if (!$aAttributeDescriptions) $aAttributeDescriptions=array(); - Yii::app()->db->createCommand($sSurveyUpdateQuery)->execute(array(':attributedescriptions'=>json_encode($aAttributeDescriptions))); + Yii::app()->db->createCommand($sSurveyUpdateQuery)->execute(array(':attributedescriptions'=>json_encode($aAttributeDescriptions),':surveyid'=>$aSurveyRow['sid'])); } }