# HG changeset patch # User Dan # Date 1215835673 14400 # Node ID be0e904eec174c1ef731e6adea388074ecd1178e # Parent 0122f538c242530c719e5363c5caa4aa8136cdb1 Refined upgrade process a bit. Uses libenanoinstall (incomplete), and post stage added to flush caches and import new strings diff -r 0122f538c242 -r be0e904eec17 includes/lang.php --- a/includes/lang.php Sat Jul 12 00:07:23 2008 -0400 +++ b/includes/lang.php Sat Jul 12 00:07:53 2008 -0400 @@ -76,7 +76,7 @@ { global $db, $session, $paths, $template, $plugins; // Common objects - if ( defined('IN_ENANO_INSTALL') && ( !defined('ENANO_CONFIG_FETCHED') || defined('IN_ENANO_UPGRADE') ) ) + if ( defined('IN_ENANO_INSTALL') && ( !defined('ENANO_CONFIG_FETCHED') || ( defined('IN_ENANO_UPGRADE') && !defined('IN_ENANO_UPGRADE_POST') ) ) ) { // special case for the Enano installer: it will load its own strings from a JSON file and just use this API for fetching // and templatizing them. @@ -312,10 +312,11 @@ /** * Imports a JSON-format language file into the database and merges with current strings. * @param string Path to the JSON file to load + * @param bool If true, only imports new strings and skips those that already exist. Defaults to false (import all strings) * @param bool Enable debugging output, makes the process over CLI more interesting */ - function import($file, $debug = false) + function import($file, $skip_existing = false, $debug = false) { global $db, $session, $paths, $template, $plugins; // Common objects @@ -367,7 +368,7 @@ if ( $debug ) echo " Starting string import$br\n"; - return $this->import_array($langdata, $debug); + return $this->import_array($langdata, $skip_existing, $debug); } /** @@ -437,11 +438,12 @@ /** * Performs the actual import of string data. * @param array Parsed JSON object, should be in the form of an array + * @param bool If true, only imports new strings and skips those that already exist. Defaults to false. * @param bool Enable debugging output * @access private */ - protected function import_array($langdata, $debug = false) + protected function import_array($langdata, $skip_existing = false, $debug = false) { global $db, $session, $paths, $template, $plugins; // Common objects @@ -465,6 +467,17 @@ } foreach ( $langdata['strings'][$category] as $string_name => $string_value ) { + // should we skip this string? + if ( isset($this->strings[$category]) && $skip_existing ) + { + if ( isset($this->strings[$category][$string_name]) ) + { + // already exists, skip + if ( $debug ) + echo " Skipping string (already exists): {$category}_{$string_name}$br\n"; + continue; + } + } $string_name = $db->escape($string_name); $string_value = $db->escape($string_value); $category_name = $db->escape($category); diff -r 0122f538c242 -r be0e904eec17 install/includes/common.php --- a/install/includes/common.php Sat Jul 12 00:07:23 2008 -0400 +++ b/install/includes/common.php Sat Jul 12 00:07:53 2008 -0400 @@ -148,7 +148,7 @@ if ( count($languages) < 1 ) { - die('CRITICAL: No languages are available'); + die('The Enano installer couldn\'t find any languages in the language/ folder. Enano needs at least one language in this folder to load and install properly.'); } // List of available DB drivers diff -r 0122f538c242 -r be0e904eec17 install/includes/libenanoinstall.php --- a/install/includes/libenanoinstall.php Sat Jul 12 00:07:23 2008 -0400 +++ b/install/includes/libenanoinstall.php Sat Jul 12 00:07:53 2008 -0400 @@ -92,6 +92,7 @@ close_install_table(); $post_data = ''; $mysql_error = mysql_error(); + $file = ( defined('IN_ENANO_UPGRADE') ) ? 'upgrade.php' : 'install.php'; foreach ( $_POST as $key => $value ) { // FIXME: These should really also be sanitized for double quotes @@ -102,7 +103,7 @@ if ( $stage_id == 'renameconfig' ) echo '
' . $failure_explanation . '
'; else - echo ' diff -r 0122f538c242 -r be0e904eec17 install/upgrade.php --- a/install/upgrade.php Sat Jul 12 00:07:23 2008 -0400 +++ b/install/upgrade.php Sat Jul 12 00:07:53 2008 -0400 @@ -137,6 +137,10 @@ { $ui->set_visible_stage($stg_upgrade); } +else if ( isset($_GET['stage']) && @$_GET['stage'] == 'postpimp' ) +{ + $ui->set_visible_stage($stg_finish); +} else { $ui->set_visible_stage($stg_confirm); @@ -196,9 +200,58 @@ // Do the actual upgrade enano_perform_upgrade($target_branch); - $site_url = makeUrl(getConfig('main_page'), false, true); - echo 'All done! I\'ll actually be nice enough to give you a link back to your site this release :)
'; - echo 'It is important that you run a language string re-import and then clear your browser cache. Otherwise you may see bits of the interface that appear to not be localized. This process will be automatic and non-destructive in later versions.
'; + // Mark as upgrade-in-progress + setConfig('enano_version', 'upg-' . installer_enano_version()); + + ?> ++ get('upgrade_msg_schema_complete_body'); ?> +
+ + ' . $lang->get('upgrade_err_post_not_available') . ''; + $ui->show_footer(); + $db->close(); + exit(); + } + + function stg_load_files() + { + if ( !@include( ENANO_ROOT . "/install/includes/payload.php" ) ) + return false; + + return true; + } + + echo '' . $lang->get('upgrade_post_status_body') . '
'; + + start_install_table(); + run_installer_stage('load', $lang->get('install_stg_load_title'), 'stg_load_files', $lang->get('install_stg_load_body'), false); + run_installer_stage('importlang', $lang->get('install_stg_importlang_title'), 'stg_lang_import', $lang->get('install_stg_importlang_body')); + run_installer_stage('flushcache', $lang->get('upgrade_stg_flushcache_title'), 'stg_flush_cache', $lang->get('upgrade_stg_flushcache_body')); + run_installer_stage('setversion', $lang->get('upgrade_stg_setversion_title'), 'stg_set_version', $lang->get('upgrade_stg_setversion_body')); + close_install_table(); + + $link_home = makeUrl(getConfig('main_page'), false, true); + echo '' . $lang->get('upgrade_post_status_finish_body', array('mainpage_link' => $link_home)) . '
'; } else { diff -r 0122f538c242 -r be0e904eec17 language/english/install.json --- a/language/english/install.json Sat Jul 12 00:07:23 2008 -0400 +++ b/language/english/install.json Sat Jul 12 00:07:53 2008 -0400 @@ -373,6 +373,18 @@ confirm_objective_backup_fs: 'Back up Enano installation directory (%dir%)', confirm_objective_backup_db: 'Back up Enano database, including non-Enano tables if any (%dbname%)', confirm_btn_upgrade: 'Pimp my Enano!', + + err_post_not_available: 'You\'re trying to run the post-upgrade process, but your site isn\'t in the correct state for this.', + + post_status_title: 'Finishing upgrade', + post_status_body: 'Enano is cleaning up some data and finalizing the upgrade.', + post_status_finish_title: 'All done!', + post_status_finish_body: 'That\'s it - Enano has been upgraded. You should go back to your site now and make sure that everything works right. If you find a problem, be sure to report it to the Enano development team. (Make sure you disable any plugins first, since we can\'t easily tell if your problem is caused by the Enano core or by a plugin.)', + + stg_flushcache_title: 'Flush caches', + stg_flushcache_body: 'The upgrader failed to delete some cached data. You may experience some problems with file corruption or badly drawn pages until the caches expire, which is often no longer than 20 minutes.', + stg_setversion_title: 'Set Enano version and log upgrade', + stg_setversion_body: 'There was a problem finalizing the upgrade and inserting logs. You really shouldn\'t ever see this message, but calling setConfig(\'enano_version\', installer_enano_version()) should get you rolling again since everything else is probably done by now.', } } }