diff --git a/application/controllers/admin/checkintegrity.php b/application/controllers/admin/checkintegrity.php index 741e081b182..799093a1201 100644 --- a/application/controllers/admin/checkintegrity.php +++ b/application/controllers/admin/checkintegrity.php @@ -252,7 +252,7 @@ private function _deleteQuotaMembers(array $aData) /** * This function Deletes quota language settings without related main entries - * + * */ private function _deleteQuotaLanguageSettings() { @@ -265,8 +265,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) { @@ -359,6 +359,8 @@ protected function _checkintegrity() $sDBPrefix = Yii::app()->db->tablePrefix; $sQuery = dbSelectTablesLike('{{survey}}\_%'); $aResult = dbQueryOrFalse($sQuery); + $sSurveyIDs = Yii::app()->db->createCommand('select sid from {{surveys}}')->queryColumn(); + foreach ($aResult->readAll() as $aRow) { $sTableName = substr(reset($aRow), strlen($sDBPrefix)); @@ -367,7 +369,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}"; @@ -386,7 +388,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}";