Skip to content

Commit

Permalink
Fixed issue: Database not completely updated if updating from an earl…
Browse files Browse the repository at this point in the history
…ier version than 2.6.x

Dev Show info message and prevent update
  • Loading branch information
c-schmitz committed Oct 18, 2017
1 parent 66e8d24 commit d0ae870
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 20 deletions.
21 changes: 17 additions & 4 deletions application/helpers/update/updatedb_helper.php
Expand Up @@ -33,6 +33,11 @@ function db_upgrade_all($iOldDBVersion, $bSilent=false) {
if ($bSilent && (count(array_intersect($aCriticalDBVersions,$aAllUpdates))>0)){
return false;
}
// If DBVersion is older than 258 don't allow database update
If ($iOldDBVersion<258)
{
return false;
}

/// This function does anything necessary to upgrade
/// older versions to match current functionality
Expand Down Expand Up @@ -1142,7 +1147,12 @@ function rollBackToTransactionBookmark($sBookmark='limesurvey')
}
}


/**
* Drop a default value in MSSQL
*
* @param mixed $fieldname
* @param mixed $tablename
*/
function dropDefaultValueMSSQL($fieldname, $tablename)
{
// find out the name of the default constraint
Expand All @@ -1161,7 +1171,7 @@ function dropDefaultValueMSSQL($fieldname, $tablename)
}

/**
* This function drops a unique Key of an MSSQL database field by using the name of the field it lies upon and the table name
* This function drops a unique Key of an MSSQL database field by using the field name and the table name
*
* @param string $sFieldName
* @param string $sTableName
Expand All @@ -1179,8 +1189,11 @@ function dropUniqueKeyMSSQL($sFieldName, $sTableName)
}

/**
* @param string $sFieldName
*/
* This function drops a secondary key of an MSSQL database field by using the field name and the table name
*
* @param mixed $sFieldName
* @param mixed $sTableName
*/
function dropSecondaryKeyMSSQL($sFieldName, $sTableName)
{
$oDB = Yii::app()->getDb();
Expand Down
46 changes: 30 additions & 16 deletions application/views/admin/databaseupdate/verify.php
Expand Up @@ -2,23 +2,37 @@
<h2 class=""><?php eT('Database upgrade'); ?></h2>
<p class="lead"><?php eT('Please verify the following information before continuing with the database upgrade:'); ?></p>
<div class="row">
<div class="col-md-offset-4 col-md-4">
<table class="table table-striped">
<tr><th><?php eT('Database type:'); ?></th><td><?php echo Yii::app()->db->getDriverName(); ?></td></tr>
<tr><th><?php eT('Database name:'); ?></th><td><?php echo getDBConnectionStringProperty('dbname'); ?></td></tr>
<tr><th><?php eT('Table prefix:'); ?></th><td><?php echo Yii::app()->db->tablePrefix; ?></td></tr>
<tr><th><?php eT('Site name:'); ?></th><td><?php echo Yii::app()->getConfig("sitename"); ?></td></tr>
<tr><th><?php eT('Root URL:'); ?></th><td><?php echo Yii::app()->getController()->createUrl('/'); ?></td></tr>
<tr><th><?php eT('Current database version:'); ?></th><td><?php echo GetGlobalSetting('DBVersion'); ?></td></tr>
<tr><th><?php eT('Target database version:'); ?></th><td><?php echo Yii::app()->getConfig('dbversionnumber'); ?></td></tr>
</table>
</div>
<div class="col-md-offset-4 col-md-4">
<table class="table table-striped">
<tr><th><?php eT('Database type:'); ?></th><td><?php echo Yii::app()->db->getDriverName(); ?></td></tr>
<tr><th><?php eT('Database name:'); ?></th><td><?php echo getDBConnectionStringProperty('dbname'); ?></td></tr>
<tr><th><?php eT('Table prefix:'); ?></th><td><?php echo Yii::app()->db->tablePrefix; ?></td></tr>
<tr><th><?php eT('Site name:'); ?></th><td><?php echo Yii::app()->getConfig("sitename"); ?></td></tr>
<tr><th><?php eT('Root URL:'); ?></th><td><?php echo Yii::app()->getController()->createUrl('/'); ?></td></tr>
<tr><th><?php eT('Current database version:'); ?></th><td><?php echo GetGlobalSetting('DBVersion'); ?></td></tr>
<tr><th><?php eT('Target database version:'); ?></th><td><?php echo Yii::app()->getConfig('dbversionnumber'); ?></td></tr>
</table>
</div>
</div>

<p>
<a class="btn btn-lg btn-success" href="<?php echo Yii::app()->getController()->createUrl("admin/databaseupdate/sa/db/continue/yes"); ?>" role="button">
<?php eT('Click here to continue'); ?>
</a>
</p>
<?php if ((int)GetGlobalSetting('DBVersion')<258) { ?>
<div class="alert alert-danger" role="alert">
<strong><?php echo eT("Error:"); ?></strong> <?php eT("You will not be able to update because your previous LimeSurvey version is too old.");?>
<br>
<?php eT("Please first update to Version 2.6.x or later before you update to Version 3.x."); ?>
</div>


<?php }
else
{ ?>


<p>
<a class="btn btn-lg btn-success" href="<?php echo Yii::app()->getController()->createUrl("admin/databaseupdate/sa/db/continue/yes"); ?>" role="button">
<?php eT('Start database upgrade'); ?>
</a>
</p>
<?php } ?>

</div>

0 comments on commit d0ae870

Please sign in to comment.