Skip to content

Commit

Permalink
Fixed issue CR-1156: error and save pages were loading twig files of …
Browse files Browse the repository at this point in the history
…wrong su… (#3164)

* Fixed issue: error and save pages were loading twig files of wrong surveytheme

* Dev: added second possible param for survey id in error action

* Dev: fix code formatting
  • Loading branch information
twilligls committed Jun 8, 2023
1 parent fb0aa68 commit a84da20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 8 additions & 5 deletions application/controllers/SurveysController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function actionError()
// TODO: Remove? It seems this can never happen because it's already caught by LSYii_Application::onException() (see commit c792c2e).
$this->spitOutJsonError($error, $oException);
} elseif ($error) {
$this->spitOutHtmlError($error, $oException);
$this->spitOutHtmlError($error, $request->getParam('sid', $request->getParam('surveyid')));
} else {
throw new CHttpException(404, 'Page not found.');
}
Expand All @@ -96,7 +96,7 @@ public function actionError()
* Echo $error as HTML and end execution.
*
* @param array $error
* @param CException|null $oException
* @param string|null $surveyId
*
* @return void
*
Expand All @@ -106,10 +106,13 @@ public function actionError()
* @throws Twig_Error_Syntax
* @throws WrongTemplateVersionException
*/
public function spitOutHtmlError(array $error, $oException = null)
public function spitOutHtmlError(array $error, $surveyId)
{
// TODO: getGlobalSetting is DEPRECATED.
$oTemplate = Template::model()->getInstance(getGlobalSetting('defaulttheme'));
if ($surveyId) {
$oTemplate = Template::model()->getInstance('', $surveyId);
} else {
$oTemplate = Template::getLastInstance();
}
$this->sTemplate = $oTemplate->sTemplateName;

$admin = App()->getConfig('siteadminname');
Expand Down
4 changes: 0 additions & 4 deletions application/libraries/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ function getSaveFormDatas($iSurveyId)
$thisstep = $_SESSION['survey_' . $iSurveyId]['step'] ?? 0;
$clienttoken = $_SESSION['survey_' . $iSurveyId]['token'] ?? '';

$oSurvey = Survey::model()->findByPk($iSurveyId);
$sTemplate = $oSurvey->template;
$oTemplate = Template::model()->getInstance($sTemplate);

$aSaveForm['aErrors'] = $this->aSaveErrors;
$this->launchSaveFormEvent($iSurveyId);
/* Construction of the form */
Expand Down

0 comments on commit a84da20

Please sign in to comment.