diff --git a/application/models/QuestionAttribute.php b/application/models/QuestionAttribute.php index a705c9059e1..16f2a037627 100644 --- a/application/models/QuestionAttribute.php +++ b/application/models/QuestionAttribute.php @@ -209,7 +209,8 @@ public function setMultiple($iSid, $aQids, $aAttributesToUpdate, $aValidQuestion */ public function getQuestionAttributes($iQuestionID, $sLanguage = null) { - $iQuestionID = (int) $iQuestionID; + static $survey = ''; + $iQuestionID = (int)$iQuestionID; // Limit the size of the attribute cache due to memory usage $cacheKey = 'getQuestionAttributes_' . $iQuestionID . '_' . json_encode($sLanguage); if (EmCacheHelper::useCache()) { @@ -218,12 +219,16 @@ public function getQuestionAttributes($iQuestionID, $sLanguage = null) return $value; } } - $oQuestion = Question::model()->with('survey')->find("qid=:qid", array('qid' => $iQuestionID)); + + $oQuestion = Question::model()->find("qid=:qid", ['qid' => $iQuestionID]); if ($oQuestion) { + if (!$survey) { + $survey = Survey::model()->findByPk($oQuestion->sid); + } if ($sLanguage) { - $aLanguages = array($sLanguage); + $aLanguages = [$sLanguage]; } else { - $aLanguages = $oQuestion->survey->allLanguages; + $aLanguages = $survey->allLanguages; } // For some reason this happened in bug #10684 if ($oQuestion->type == null) {