Skip to content

Commit

Permalink
Fixed issue #17458: Check integrty broke fpor subquestion with only n…
Browse files Browse the repository at this point in the history
…umber (#2313)

Dev: Try cast and don't throw error
  • Loading branch information
Shnoulle committed Jul 20, 2022
1 parent 8965fb5 commit 1dc8b53
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions application/controllers/admin/CheckIntegrity.php
Expand Up @@ -633,12 +633,14 @@ protected function checkintegrity()
// It was just the QID....
$sQID = $sDirtyQid;
}
if ((string) intval($sQID) !== $sQID) {
throw new \Exception('sQID is not an integer: ' . $sQID);
}

// Here, we get the question as defined in backend
$oQuestion = Question::model()->findByAttributes([ 'qid' => $sQID , 'sid' => $oSurvey->sid ]);
try {
$oQuestion = Question::model()->findByAttributes([ 'qid' => $sQID , 'language' => $oSurvey->language, 'sid' => $oSurvey->sid ]);

This comment has been minimized.

Copy link
@gabrieljenik

gabrieljenik Sep 16, 2022

Collaborator

@Shnoulle

Language is no longer in Question model.
Maybe that may cause an exception.

Got to these while reviewing
17042: Bug in integrity controller

This comment has been minimized.

Copy link
@Shnoulle

Shnoulle Sep 16, 2022

Author Collaborator

Arg copy/pasted from 3.X i fix in a minute

} catch (Exception $e) {
// QID potentially invalid , see #17458, reset $oQuestion
$oQuestion = null;
}
if (is_a($oQuestion, 'Question')) {
// We check if its GID is the same as the one defined in the column name
if ($oQuestion->gid != $sGid) {
Expand Down

0 comments on commit 1dc8b53

Please sign in to comment.