Skip to content

Commit

Permalink
merge r16312 from branch 2.4 to trunk
Browse files Browse the repository at this point in the history
bug 2677 fixed: smarter check of the database version and manage partial upgrade.



git-svn-id: http://piwigo.org/svn/trunk@16313 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Jul 2, 2012
1 parent 39d5409 commit 52fa0fe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
13 changes: 10 additions & 3 deletions install/upgrade_2.3.0.php
Expand Up @@ -52,7 +52,7 @@
$inserts = array();
foreach ($to_apply as $upgrade_id)
{
if ($upgrade_id >= 98)
if ($upgrade_id >= 112) // TODO change on each release
{
break;
}
Expand Down Expand Up @@ -83,11 +83,18 @@
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);
Expand Down
25 changes: 20 additions & 5 deletions upgrade.php
Expand Up @@ -322,13 +322,28 @@ function print_time($message)
{
$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();
}
}

// +-----------------------------------------------------------------------+
Expand Down

0 comments on commit 52fa0fe

Please sign in to comment.