Skip to content

Commit

Permalink
Fixed issue #19426: Survey listing - multiple call of same user (#3785)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Apr 16, 2024
1 parent c6bed76 commit 49b0ede
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
15 changes: 12 additions & 3 deletions application/models/Survey.php
Expand Up @@ -179,7 +179,6 @@ class Survey extends LSActiveRecord implements PermissionInterface
private $sSurveyUrl;

/**
* Set defaults
* @inheritdoc
*/
public function init()
Expand All @@ -190,6 +189,18 @@ public function init()
$this->gsid = null;
return;
}
if ($this->isNewRecord) {
$this->setAttributeDefaults();
}
$this->attachEventHandler("onAfterFind", array($this, 'afterFindSurvey'));
}

/**
* Set the default values for new record
* @return void
*/
public function setAttributeDefaults()
{
// Set the default values
$this->htmlemail = 'Y';
$this->format = 'G';
Expand Down Expand Up @@ -221,8 +232,6 @@ public function init()
}
}
}

$this->attachEventHandler("onAfterFind", array($this, 'afterFindSurvey'));
}

/** @inheritdoc */
Expand Down
7 changes: 6 additions & 1 deletion application/models/SurveysGroupsettings.php
Expand Up @@ -407,7 +407,12 @@ protected static function translateOptionLabels($instance, $attribute, $value)
} elseif ($attribute == 'owner_id' && $value != -1) {
$instance->oOptions->owner = "";
$instance->oOptions->ownerLabel = "";
$oUser = User::model()->findByPk($instance->oOptions->{$attribute});
/* \User|null[] see mantis #19426 */
static $oStaticUsers = array();
if (!array_key_exists($instance->oOptions->{$attribute}, $oStaticUsers)) { // use array_key_exists for null value
$oStaticUsers[$instance->oOptions->{$attribute}] = User::model()->findByPk($instance->oOptions->{$attribute});
}
$oUser = $oStaticUsers[$instance->oOptions->{$attribute}];
if (!empty($oUser)) {
$instance->oOptions->owner = $oUser->attributes;
$instance->oOptions->ownerLabel = $oUser->users_name . ($oUser->full_name ? " - " . $oUser->full_name : "");
Expand Down

0 comments on commit 49b0ede

Please sign in to comment.