Skip to content

Commit

Permalink
Fixed issue #16673: afterFindSurvey fired to many times
Browse files Browse the repository at this point in the history
  • Loading branch information
ptelu committed Mar 26, 2021
1 parent dbc6b37 commit 6ef50d6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions application/models/QuestionAttribute.php
Expand Up @@ -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()) {
Expand All @@ -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) {
Expand Down

1 comment on commit 6ef50d6

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.