Skip to content

Commit

Permalink
Fixed issue #9771: Unable to directly upgrade from 1.87 to 2.06
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Jul 24, 2015
1 parent 0306baf commit 846d038
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
18 changes: 6 additions & 12 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -368,7 +368,7 @@ function db_upgrade_all($iOldDBVersion) {
$oDB->createCommand()->createIndex('sess2_expiry','{{sessions}}','expiry');
$oDB->createCommand()->createIndex('sess2_expireref','{{sessions}}','expireref');
// Move all user templates to the new user template directory
echo sprintf(gT("Moving user templates to new location at %s..."),$sUserTemplateRootDir)."<br />";
echo "<br>".sprintf(gT("Moving user templates to new location at %s..."),$sUserTemplateRootDir)."<br />";
$hTemplateDirectory = opendir($sStandardTemplateRootDir);
$aFailedTemplates=array();
// get each entry
Expand Down Expand Up @@ -480,7 +480,7 @@ function db_upgrade_all($iOldDBVersion) {
// change the primary index to include language
if (Yii::app()->db->driverName=='mysql') // special treatment for mysql because this needs to be in one step since an AUTOINC field is involved
{
modifyPrimaryKey('{{assessments}}', array('id', 'language'));
modifyPrimaryKey('assessments', array('id', 'language'));
}
else
{
Expand Down Expand Up @@ -1641,17 +1641,11 @@ function upgradePermissions166()

function upgradeSurveys156()
{
global $modifyoutput;
$sSurveyQuery = "SELECT * FROM {{surveys_languagesettings}}";
$oSurveyResult = $oDB->createCommand($sSurveyQuery)->queryAll();
$oSurveyResult = Yii::app()->getDb()->createCommand($sSurveyQuery)->queryAll();
foreach ( $oSurveyResult as $aSurveyRow )
{

Yii::app()->loadLibrary('Limesurvey_lang',array("langcode"=>$aSurveyRow['surveyls_language']));
$sLanguage = App()->language;
$aDefaultTexts=templateDefaultTexts($sLanguage,'unescaped');
unset($sLanguage);

$aDefaultTexts=templateDefaultTexts($aSurveyRow['surveyls_language'],'unescaped');
if (trim(strip_tags($aSurveyRow['surveyls_email_confirm'])) == '')
{
$sSurveyUpdateQuery= "update {{surveys}} set sendconfirmation='N' where sid=".$aSurveyRow['surveyls_survey_id'];
Expand Down Expand Up @@ -1755,7 +1749,7 @@ function upgradeSurveys145()
}
}
$sSurveyQuery = "SELECT * FROM {{surveys_languagesettings}}";
$oSurveyResult = $oDB->createCommand($sSurveyQuery)->queryAll();
$oSurveyResult = Yii::app()->getDb()->createCommand($sSurveyQuery)->queryAll();
foreach ( $oSurveyResult as $aSurveyRow )
{
$sLanguage = App()->language;
Expand Down Expand Up @@ -2174,7 +2168,7 @@ function alterLanguageCode($sOldLanguageCode,$sNewLanguageCode)

function addPrimaryKey($sTablename, $aColumns)
{
return Yii::app()->db->createCommand()->addPrimaryKey('PRIMARY', $sTablename, $aColumns);
return Yii::app()->db->createCommand()->addPrimaryKey('PRIMARY', '{{'.$sTablename.'}}', $aColumns);
}

/**
Expand Down
24 changes: 14 additions & 10 deletions application/models/LSActiveRecord.php
Expand Up @@ -24,6 +24,7 @@ class LSActiveRecord extends CActiveRecord
* @return array
*/
public function behaviors(){
$aBehaviors=array();
$sCreateFieldName=($this->hasAttribute('created')?'created':null);
$sUpdateFieldName=($this->hasAttribute('modified')?'modified':null);
$sDriverName = Yii::app()->db->getDriverName();
Expand All @@ -35,17 +36,20 @@ public function behaviors(){
{
$sTimestampExpression=new CDbExpression('NOW()');
}
return array(
'PluginEventBehavior' => array(
'class' => 'application.models.behaviors.PluginEventBehavior'
),
'CTimestampBehavior' => array(
'class' => 'zii.behaviors.CTimestampBehavior',
'createAttribute' => $sCreateFieldName,
'updateAttribute' => $sUpdateFieldName,
'timestampExpression' => $sTimestampExpression
)
$aBehaviors['CTimestampBehavior'] = array(
'class' => 'zii.behaviors.CTimestampBehavior',
'createAttribute' => $sCreateFieldName,
'updateAttribute' => $sUpdateFieldName,
'timestampExpression' => $sTimestampExpression
);
// Table plugins might not exist during a database upgrade so in that case disconnect events
if (Yii::app()->db->schema->getTable('{{plugins}}') !== null)
{
$aBehaviors['PluginEventBehavior']= array(
'class' => 'application.models.behaviors.PluginEventBehavior'
);
}
return $aBehaviors;
}

/**
Expand Down

0 comments on commit 846d038

Please sign in to comment.