aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2012-07-02 22:28:07 +0000
committerplegall <plg@piwigo.org>2012-07-02 22:28:07 +0000
commitb85adcaa734b9aab1f64b6ec1551f3a43c62054e (patch)
treec367081b4c1be3898f0700a47f418a0ae65bdbba
parent968d32fde2be7bf6135f6392114c5dd4033e1345 (diff)
bug 2677 fixed: smarter check of the database version and manage partial upgrade.
git-svn-id: http://piwigo.org/svn/branches/2.4@16312 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--install/upgrade_2.3.0.php13
-rw-r--r--upgrade.php25
2 files changed, 30 insertions, 8 deletions
diff --git a/install/upgrade_2.3.0.php b/install/upgrade_2.3.0.php
index c1aa07df7..0dc5c139c 100644
--- a/install/upgrade_2.3.0.php
+++ b/install/upgrade_2.3.0.php
@@ -52,7 +52,7 @@ $to_apply = array_diff($existing, $applied);
$inserts = array();
foreach ($to_apply as $upgrade_id)
{
- if ($upgrade_id >= 98)
+ if ($upgrade_id >= 112) // TODO change on each release
{
break;
}
@@ -83,11 +83,18 @@ if (!empty($inserts))
ob_start();
echo '<pre>';
-for ($upgrade_id = 112; $upgrade_id <= 127; $upgrade_id++)
+for ($upgrade_id = 112; $upgrade_id <= 127; $upgrade_id++) // TODO change on each release
{
if (!file_exists(UPGRADES_PATH.'/'.$upgrade_id.'-database.php'))
{
- break;
+ continue;
+ }
+
+ // maybe the upgrade task has already been applied in a previous and
+ // incomplete upgrade
+ if (in_array($upgrade_id, $applied))
+ {
+ continue;
}
unset($upgrade_description);
diff --git a/upgrade.php b/upgrade.php
index b0edd7609..8a7471b94 100644
--- a/upgrade.php
+++ b/upgrade.php
@@ -322,13 +322,28 @@ else if (!in_array('rating_score', $columns_of[PREFIX_TABLE.'images']))
{
$current_release = '2.2.0';
}
-else if (!in_array('coi', $columns_of[PREFIX_TABLE.'images']))
-{
- $current_release = '2.3.0';
-}
else
{
- die('No upgrade required, the database structure is up to date');
+ // retrieve already applied upgrades
+ $query = '
+SELECT id
+ FROM '.PREFIX_TABLE.'upgrade
+;';
+ $applied_upgrades = array_from_query($query, 'id');
+
+ if (!in_array(127, $applied_upgrades))
+ {
+ $current_release = '2.3.0';
+ }
+ else
+ {
+ // confirm that the database is in the same version as source code files
+ conf_update_param('piwigo_db_version', get_branch_from_version(PHPWG_VERSION));
+
+ echo 'No upgrade required, the database structure is up to date';
+ echo '<br><a href="index.php">← back to gallery</a>';
+ exit();
+ }
}
// +-----------------------------------------------------------------------+