Skip to content

Commit

Permalink
Fixed issue #9457: Error in integrity check when using MSSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Aug 24, 2015
1 parent 3041b5c commit f93951b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions application/controllers/admin/checkintegrity.php
Expand Up @@ -250,7 +250,7 @@ private function _deleteQuotaMembers(array $aData)

/**
* This function Deletes quota language settings without related main entries
*
*
*/
private function _deleteQuotaLanguageSettings()
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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));
Expand All @@ -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}";
Expand All @@ -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}";
Expand Down

0 comments on commit f93951b

Please sign in to comment.