Skip to content

Commit

Permalink
Fixed issue #17221: Check data integrity crash with SQL error when # …
Browse files Browse the repository at this point in the history
…is use in the name of field
  • Loading branch information
olleharstedt committed Apr 6, 2021
1 parent 50ed575 commit 3912d51
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion application/controllers/admin/checkintegrity.php
Expand Up @@ -521,14 +521,17 @@ protected function _checkintegrity()
// QID field can be more than just QID, like: 886other or 886A1
// So we clean it by finding the first alphabetical character
$sDirtyQid = $aFields[2];
preg_match('~[a-zA-Z_]~i', $sDirtyQid, $match, PREG_OFFSET_CAPTURE);
preg_match('~[a-zA-Z_#]~i', $sDirtyQid, $match, PREG_OFFSET_CAPTURE);

if (isset($match[0][1])){
$sQID = substr ($sDirtyQid, 0, $match[0][1]);
}else{
// 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 , 'language' => $oSurvey->language, 'sid' => $oSurvey->sid ]);
Expand Down

0 comments on commit 3912d51

Please sign in to comment.