From 7f895d7c4a00a45e3fdb1be1927c3e0e044df331 Mon Sep 17 00:00:00 2001 From: plegall Date: Tue, 2 Nov 2021 16:51:20 +0100 Subject: [PATCH] fixes #1544 upgrade script from 11 to 12 --- install/upgrade_11.0.0.php | 111 +++++++++++++++++++++++++++++++++++++ install/upgrade_2.10.0.php | 2 +- upgrade.php | 16 ++++-- 3 files changed, 123 insertions(+), 6 deletions(-) create mode 100644 install/upgrade_11.0.0.php diff --git a/install/upgrade_11.0.0.php b/install/upgrade_11.0.0.php new file mode 100644 index 000000000..eb8d50d90 --- /dev/null +++ b/install/upgrade_11.0.0.php @@ -0,0 +1,111 @@ += 160) // TODO change on each release (first task to run) + { + break; + } + + array_push( + $inserts, + array( + 'id' => $upgrade_id, + 'applied' => CURRENT_DATE, + 'description' => '[migration from 11.0.0 to '.PHPWG_VERSION.'] not applied', // TODO change on each release + ) + ); +} + +if (!empty($inserts)) +{ + mass_inserts( + '`'.UPGRADE_TABLE.'`', + array_keys($inserts[0]), + $inserts + ); +} + +// +-----------------------------------------------------------------------+ +// | Perform upgrades | +// +-----------------------------------------------------------------------+ + +ob_start(); +echo '
';
+
+for ($upgrade_id = 160; $upgrade_id <= 162; $upgrade_id++) // TODO change on each release
+{
+  if (!file_exists(UPGRADES_PATH.'/'.$upgrade_id.'-database.php'))
+  {
+    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);
+
+  echo "\n\n";
+  echo '=== upgrade '.$upgrade_id."\n";
+
+  // include & execute upgrade script. Each upgrade script must contain
+  // $upgrade_description variable which describe briefly what the upgrade
+  // script does.
+  $up_start = get_moment();
+  include(UPGRADES_PATH.'/'.$upgrade_id.'-database.php');
+
+  // notify upgrade (TODO change on each release)
+  $query = '
+INSERT INTO `'.PREFIX_TABLE.'upgrade`
+  (id, applied, description)
+  VALUES
+  (\''.$upgrade_id.'\', NOW(), \'[migration from 11.0.0 to '.PHPWG_VERSION.', '.get_elapsed_time($up_start, get_moment()).'] '.$upgrade_description.'\')
+;';
+  pwg_query($query);
+}
+
+echo '
'; +ob_end_clean(); + +// now we upgrade from 12.0.0 +// include_once(PHPWG_ROOT_PATH.'install/upgrade_12.0.0.php'); +?> diff --git a/install/upgrade_2.10.0.php b/install/upgrade_2.10.0.php index 1fe1d0b84..d4e226277 100644 --- a/install/upgrade_2.10.0.php +++ b/install/upgrade_2.10.0.php @@ -107,5 +107,5 @@ echo ''; ob_end_clean(); // now we upgrade from 11.0.0 -// include_once(PHPWG_ROOT_PATH.'install/upgrade_11.0.0.php'); +include_once(PHPWG_ROOT_PATH.'install/upgrade_11.0.0.php'); ?> diff --git a/upgrade.php b/upgrade.php index 5da742ca8..c2fb1d593 100644 --- a/upgrade.php +++ b/upgrade.php @@ -189,11 +189,6 @@ load_language( 'common.lang', '', array('language'=>$language, 'target_charset'= load_language( 'admin.lang', '', array('language'=>$language, 'target_charset'=>'utf-8', 'no_fallback' => true) ); load_language( 'install.lang', '', array('language'=>$language, 'target_charset'=>'utf-8', 'no_fallback' => true) ); load_language( 'upgrade.lang', '', array('language'=>$language, 'target_charset'=>'utf-8', 'no_fallback' => true) ); -// check php version -if (version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '<')) -{ - include(PHPWG_ROOT_PATH.'install/php5_apache_configuration.php'); -} // +-----------------------------------------------------------------------+ // | database connection | @@ -353,6 +348,10 @@ SELECT id { $current_release = '2.10.0'; } + else if (!in_array(162, $applied_upgrades)) + { + $current_release = '11.0.0'; + } else { // confirm that the database is in the same version as source code files @@ -372,6 +371,13 @@ $page['infos'] = array(); $page['errors'] = array(); $mysql_changes = array(); +// check php version +if (version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '<')) +{ + // include(PHPWG_ROOT_PATH.'install/php5_apache_configuration.php'); // to remove, with all its related content + $page['errors'][] = l10n('PHP version %s required (you are running on PHP %s)', REQUIRED_PHP_VERSION, PHP_VERSION); +} + check_upgrade_access_rights(); if ((isset($_POST['submit']) or isset($_GET['now']))