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 5821f3d commit 114bb97
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions application/controllers/admin/checkintegrity.php
Expand Up @@ -252,7 +252,7 @@ private function _deleteQuotaMembers(array $aData)

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

0 comments on commit 114bb97

Please sign in to comment.