From f93951bbf30b9c091322c9823cea333ccce3d70e Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Mon, 24 Aug 2015 14:37:30 +0200 Subject: [PATCH] Fixed issue #9457: Error in integrity check when using MSSQL --- application/controllers/admin/checkintegrity.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/application/controllers/admin/checkintegrity.php b/application/controllers/admin/checkintegrity.php index 2e54558f72b..17af63fe12e 100644 --- a/application/controllers/admin/checkintegrity.php +++ b/application/controllers/admin/checkintegrity.php @@ -250,7 +250,7 @@ private function _deleteQuotaMembers(array $aData) /** * This function Deletes quota language settings without related main entries - * + * */ private function _deleteQuotaLanguageSettings() { @@ -263,8 +263,8 @@ private function _deleteQuotaLanguageSettings() /** * This function deletes quota entries which not having a related survey entry - * - * @param mixed $aData + * + * @param mixed $aData */ private function _deleteQuotas(array $aData) { @@ -356,6 +356,7 @@ protected function _checkintegrity() /*** Check for active survey tables with missing survey entry and rename them ***/ $sDBPrefix = Yii::app()->db->tablePrefix; $aResult = App()->db->createCommand(dbSelectTablesLike('{{survey}}\_%'))->query(); + $sSurveyIDs = Yii::app()->db->createCommand('select sid from {{surveys}}')->queryColumn(); foreach ($aResult->readAll() as $aRow) { $sTableName = substr(reset($aRow), strlen($sDBPrefix)); @@ -364,7 +365,7 @@ protected function _checkintegrity() if (isset($aTableName[1]) && ctype_digit($aTableName[1])) { $iSurveyID = $aTableName[1]; - if (!in_array($iSurveyID, $sids)) { + if (!in_array($iSurveyID, $sSurveyIDs)) { $sDate = date('YmdHis') . rand(1, 1000); $sOldTable = "survey_{$iSurveyID}"; $sNewTable = "old_survey_{$iSurveyID}_{$sDate}"; @@ -383,7 +384,7 @@ protected function _checkintegrity() { $sTableName = substr(reset($aRow), strlen($sDBPrefix)); $iSurveyID = substr($sTableName, strpos($sTableName, '_') + 1); - if (!in_array($iSurveyID, $sids)) { + if (!in_array($iSurveyID, $sSurveyIDs)) { $sDate = date('YmdHis') . rand(1, 1000); $sOldTable = "tokens_{$iSurveyID}"; $sNewTable = "old_tokens_{$iSurveyID}_{$sDate}";