From 4e2d04dd4af4ee8d7be21788fe7e079bfd53e7d7 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 10 Dec 2006 14:33:21 +0000 Subject: [PATCH] implemented updater changes git-svn-id: file:///svn/phpbb/trunk@6736 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/style/install_update.html | 242 +++++++++++++++------------- phpBB/includes/acp/acp_update.php | 2 +- phpBB/install/database_update.php | 43 ++++- phpBB/install/install_update.php | 125 +++++++------- phpBB/language/en/acp/common.php | 3 + phpBB/language/en/install.php | 26 +-- 6 files changed, 264 insertions(+), 177 deletions(-) diff --git a/phpBB/adm/style/install_update.html b/phpBB/adm/style/install_update.html index be4fd0961b..9eef17200f 100644 --- a/phpBB/adm/style/install_update.html +++ b/phpBB/adm/style/install_update.html @@ -71,14 +71,16 @@ function popup(url, width, height) -
+ +
-

{L_CHECK_FILES_EXPLAIN}

- +

{L_UPDATE_DATABASE_EXPLAIN}

+
+
@@ -90,113 +92,147 @@ function popup(url, width, height)
- + -

{L_COLLECTED_INFORMATION}

+ -

{L_COLLECTED_INFORMATION_EXPLAIN}

+

{L_PERFORM_DATABASE_UPDATE}

- -
-

{L_NO_UPDATE_FILES}

+

+ {L_PERFORM_DATABASE_UPDATE_EXPLAIN}
+
+ » {L_RUN_DATABASE_SCRIPT} « +

-

{L_NO_UPDATE_FILES_EXPLAIN}


+

- {NO_UPDATE_FILES} - -
- - -
- - - - - - - - -

{files.TITLE}

- -

{files.EXPLAIN}

- -
- {files.L_STATUS} - -
- -
{files.FILENAME}
- -
- {files.DIR_PART}
{files.FILE_PART}
- -
{L_FILE_USED}: {files.CUSTOM_ORIGINAL} - - -
{L_NUM_CONFLICTS}: {files.NUM_CONFLICTS} - -
-
[ {files.L_SHOW_DIFF} ]
- -
  {L_DO_NOT_UPDATE}
- - -
-
-
  {L_MERGE_NO_MERGE_NEW_OPTION}
-
[{L_SHOW_DIFF_FINAL}]
-
-
-
  {L_MERGE_NO_MERGE_MOD_OPTION}
-
[{L_SHOW_DIFF_FINAL}]
-
-
-
  {L_MERGE_NEW_FILE_OPTION}
-
[{L_SHOW_DIFF_FINAL}]
-
-
-
  {L_MERGE_MOD_FILE_OPTION}
-
[{L_SHOW_DIFF_FINAL}]
-
- -
- -
- {files.L_STATUS} - - - - - - - + +
+
- -
- -
- -
- -
- - - -

{L_NO_DATABASE_UPDATE_NEEDED}

- -
+ + +

{L_UPDATE_DB_SUCCESS}

+ +

+ + + +
+

{L_CHECK_FILES_EXPLAIN}

+ +
+ +
+ + + + + + + +
+

{L_UPDATE_SUCCESS}

+

{L_ALL_FILES_UP_TO_DATE}

+
+ + +

{L_COLLECTED_INFORMATION}

+ +

{L_COLLECTED_INFORMATION_EXPLAIN}

+ + +
+

{L_NO_UPDATE_FILES}

+ +

{L_NO_UPDATE_FILES_EXPLAIN}


+ + {NO_UPDATE_FILES} + +
+ + +
+ + + + + +
+ + +

{files.TITLE}

+ +

{files.EXPLAIN}

+ +
+ {files.L_STATUS} + +
+ +
{files.FILENAME}
+ +
+ {files.DIR_PART}
{files.FILE_PART}
+ +
{L_FILE_USED}: {files.CUSTOM_ORIGINAL} + + +
{L_NUM_CONFLICTS}: {files.NUM_CONFLICTS} + +
+
[ {files.L_SHOW_DIFF} ]{L_BINARY_FILE}
+ +
  {L_DO_NOT_UPDATE}
+ + +
+
+
  {L_MERGE_NO_MERGE_NEW_OPTION}
+
[{L_SHOW_DIFF_FINAL}]
+
+
+
  {L_MERGE_NO_MERGE_MOD_OPTION}
+
[{L_SHOW_DIFF_FINAL}]
+
+ +
+
  {L_MERGE_NEW_FILE_OPTION}
+
[{L_SHOW_DIFF_FINAL}]
+
+
+
  {L_MERGE_MOD_FILE_OPTION}
+
[{L_SHOW_DIFF_FINAL}]
+
+ + +
+ +
+ {files.L_STATUS} + + + + + + + -
-

{L_ALL_FILES_UP_TO_DATE}

-
- +
+ +
+ +
+ +
+

{L_UPDATE_METHOD}

{L_UPDATE_METHOD_EXPLAIN}

@@ -205,9 +241,9 @@ function popup(url, width, height)    
- + - + @@ -295,16 +331,6 @@ function popup(url, width, height) - - -

{L_PERFORM_DATABASE_UPDATE}

- -

- {L_PERFORM_DATABASE_UPDATE_EXPLAIN}
-
- » {L_RUN_DATABASE_SCRIPT} « -

- diff --git a/phpBB/includes/acp/acp_update.php b/phpBB/includes/acp/acp_update.php index 140d3b7dda..050c547445 100644 --- a/phpBB/includes/acp/acp_update.php +++ b/phpBB/includes/acp/acp_update.php @@ -53,7 +53,7 @@ class acp_update 'LATEST_VERSION' => $latest_version, 'CURRENT_VERSION' => $config['version'], - 'UPDATE_INSTRUCTIONS' => sprintf($user->lang['UPDATE_INSTRUCTIONS'], $announcement_url, $update_archive_link, $update_link), + 'UPDATE_INSTRUCTIONS' => sprintf($user->lang['UPDATE_INSTRUCTIONS'], $announcement_url, $update_link), )); } } diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e5c0998be5..e9d429f45c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -60,6 +60,7 @@ require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); +$user = new user(); $cache = new cache(); $db = new $sql_db(); @@ -85,6 +86,7 @@ include($phpbb_root_path . 'language/' . $row['config_value'] . '/install.' . $p //set_error_handler('msg_handler'); // Define some variables for the database update +$inline_update = (request_var('type', 0)) ? true : false; // Database column types mapping $dbms_type_map = array( @@ -388,6 +390,21 @@ echo $lang['UPDATED_VERSION'] . ' :: ' . $updates_to_version . 'sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); +} // Schema updates ?> @@ -548,11 +565,33 @@ _write_result($no_updates, $errored, $error_ary);
-

+

+if (!$inline_update) +{ +?> + +

+ +

+ +

+ +

»

+ +ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : ''; +add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $updates_to_version); // Now we purge the session table as well as all cache files $cache->purge(); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index fed66a0a07..a62b122014 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -6,12 +6,6 @@ * @copyright (c) 2006 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * -* @todo add successful file update to log -* @todo add successful database update to log -* @todo do database update before updating files. Within the updater create a new config variable (version_update_from). Use this version in favor of the real versino to check for the database update successfully run through. After successful file update remove the information. -* @todo check memory by setting limit to 8MB locally. -* @todo make sure binary files get updated too, omitting the diff engine for this (handle like a conflict) -* @todo do not require login... * @todo check for writeable cache/store/files directory */ @@ -46,7 +40,7 @@ if (!empty($setmodules)) 'module_filename' => substr(basename(__FILE__), 0, -strlen($phpEx)-1), 'module_order' => 30, 'module_subs' => '', - 'module_stages' => array('INTRO', 'VERSION_CHECK', 'FILE_CHECK', 'UPDATE_FILES', 'UPDATE_DB'), + 'module_stages' => array('INTRO', 'VERSION_CHECK', 'UPDATE_DB', 'FILE_CHECK', 'UPDATE_FILES'), 'module_reqs' => '' ); } @@ -129,8 +123,6 @@ class install_update extends module $template->set_custom_template('../adm/style', 'admin'); // Get current and latest version - $this->current_version = $config['version']; - if (($latest_version = $cache->get('_version_info')) === false) { $this->latest_version = $this->get_file('version_info'); @@ -141,6 +133,9 @@ class install_update extends module $this->latest_version = $latest_version; } + // For the current version we trick a bit. ;) + $this->current_version = (!empty($config['version_update_from'])) ? $config['version_update_from'] : $config['version']; + $up_to_date = (version_compare(strtolower($this->current_version), strtolower($this->latest_version), '<')) ? false : true; // Check for a valid update directory, else point the user to the phpbb.com website @@ -179,18 +174,21 @@ class install_update extends module return; } - // Got the updater template itself updated? If so, we are able to directly use it - but only if all three files are present - if (in_array('adm/style/install_update.html', $this->update_info['files'])) + if ($this->test_update === false) { - $this->tpl_name = '../../install/update/new/adm/style/install_update'; - } + // Got the updater template itself updated? If so, we are able to directly use it - but only if all three files are present + if (in_array('adm/style/install_update.html', $this->update_info['files'])) + { + $this->tpl_name = '../../install/update/new/adm/style/install_update'; + } - // What about the language file? Got it updated? - if (in_array('language/en/install.php', $this->update_info['files'])) - { - $lang = array(); - include($this->new_location . 'language/en/install.php'); - $user->lang = array_merge($user->lang, $lang); + // What about the language file? Got it updated? + if (in_array('language/en/install.php', $this->update_info['files'])) + { + $lang = array(); + include($this->new_location . 'language/en/install.php'); + $user->lang = array_merge($user->lang, $lang); + } } // Include renderer and engine @@ -224,14 +222,52 @@ class install_update extends module $template->assign_vars(array( 'S_UP_TO_DATE' => $up_to_date, 'S_VERSION_CHECK' => true, - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), + + 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), + 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), 'LATEST_VERSION' => $this->latest_version, - 'CURRENT_VERSION' => $config['version']) + 'CURRENT_VERSION' => $this->current_version) ); break; + case 'update_db': + + // Make sure the database update is valid for the latest version + $valid = false; + $updates_to_version = ''; + + if (file_exists($phpbb_root_path . 'install/database_update.' . $phpEx)) + { + include_once($phpbb_root_path . 'install/database_update.' . $phpEx); + + if ($updates_to_version === $this->latest_version) + { + $valid = true; + } + } + + // Should not happen at all + if (!$valid) + { + trigger_error($user->lang['DATABASE_UPDATE_INFO_OLD'], E_USER_ERROR); + } + + // Just a precaution + $cache->purge(); + + // Redirect the user to the database update script with some explanations... + $template->assign_vars(array( + 'S_DB_UPDATE' => true, + 'S_DB_UPDATE_FINISHED' => ($config['version'] == $this->latest_version) ? true : false, + 'U_DB_UPDATE' => $phpbb_root_path . 'install/database_update.' . $phpEx . '?type=1', + 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), + 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), + )); + + break; + case 'file_check': $this->page_title = 'STAGE_FILE_CHECK'; @@ -300,6 +336,8 @@ class install_update extends module foreach ($filelist as $file_struct) { + $s_binary = (!empty($this->update_info['binary']) && in_array($file_struct['filename'], $this->update_info['binary'])) ? true : false; + $filename = htmlspecialchars($file_struct['filename']); if (strrpos($filename, '/') !== false) { @@ -323,6 +361,7 @@ class install_update extends module 'NUM_CONFLICTS' => (isset($file_struct['conflicts'])) ? $file_struct['conflicts'] : 0, 'S_CUSTOM' => ($file_struct['custom']) ? true : false, + 'S_BINARY' => $s_binary, 'CUSTOM_ORIGINAL' => ($file_struct['custom']) ? $file_struct['original'] : '', 'U_SHOW_DIFF' => $diff_url, @@ -355,6 +394,16 @@ class install_update extends module 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), )); + if ($all_up_to_date) + { + $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); + + // Add database update to log + add_log('admin', 'LOG_UPDATE_PHPBB', $this->current_version, $this->latest_version); + + $cache->purge(); + } + break; case 'update_files': @@ -703,40 +752,6 @@ class install_update extends module break; - case 'update_db': - - // Make sure the database update is valid for the latest version - $valid = false; - $updates_to_version = ''; - - if (file_exists($phpbb_root_path . 'install/database_update.' . $phpEx)) - { - include_once($phpbb_root_path . 'install/database_update.' . $phpEx); - - if ($updates_to_version === $this->latest_version) - { - $valid = true; - } - } - - // Should not happen at all - if (!$valid) - { - trigger_error($user->lang['DATABASE_UPDATE_INFO_OLD'], E_USER_ERROR); - } - - // Because we are done with the file update we purge the cache directory - $cache->purge(); - - // Redirect the user to the database update script with some explanations... - $template->assign_vars(array( - 'S_DB_UPDATE' => true, - 'U_DB_UPDATE' => $phpbb_root_path . 'install/database_update.' . $phpEx) - ); - - - - break; } } diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 40ea5cc8e4..096efc9c52 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -592,6 +592,9 @@ $lang = array_merge($lang, array( 'LOG_THEME_EXPORT' => 'Exported theme
» %s', 'LOG_THEME_REFRESHED' => 'Refreshed theme
» %s', + 'LOG_UPDATE_DATABASE' => 'Updated Database from version %1$s to version %2$s', + 'LOG_UPDATE_PHPBB' => 'Updated phpBB from version %1$s to version %2$s', + 'LOG_USER_ACTIVE' => 'User activated
» %s', 'LOG_USER_BAN_USER' => 'Banned User via user management for reason "%1$s"
» %2$s', 'LOG_USER_BAN_IP' => 'Banned IP via user management for reason "%1$s"
» %2$s', diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index b0a8171dc1..59c39e0991 100755 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -306,18 +306,21 @@ $lang = array_merge($lang, array( // Updater $lang = array_merge($lang, array( - 'ALL_FILES_UP_TO_DATE' => 'All files are up to date with the latest phpBB version. You may want to run the database update tool now.', + 'ALL_FILES_UP_TO_DATE' => 'All files are up to date with the latest phpBB version. You should now login to your board and check if everything is working fine. Do not forget to delete, rename or move your install directory!', 'ARCHIVE_FILE' => 'Source file within archive', - 'BACK' => 'Back', + 'BACK' => 'Back', + 'BINARY_FILE' => 'Binary file', 'CHECK_FILES' => 'Check files', 'CHECK_FILES_AGAIN' => 'Check files again', 'CHECK_FILES_EXPLAIN' => 'Within the next step all files will be checked against the update files - this can take a while if this is the first file check.', 'CHECK_FILES_UP_TO_DATE' => 'According to your database your version is up to date. You may want to proceed with the file check to make sure all files are really up to date with the latest phpBB version.', + 'CHECK_UPDATE_DATABASE' => 'Continue update process', 'COLLECTED_INFORMATION' => 'Information on collected files', 'COLLECTED_INFORMATION_EXPLAIN' => 'The list below shows information about the files needing an update. Please read the information in front of every status block to see what they mean and what you may need to do to perform a successful update.', 'COMPLETE_LOGIN_TO_BOARD' => 'You should now login to your board and check if everything is working fine. Do not forget to delete, rename or move your install directory!', + 'CONTINUE_INLINE_UPDATE' => 'The database update was successful. Now please close this window and continue the update process as explained.', 'CURRENT_FILE' => 'Current original file', 'CURRENT_VERSION' => 'Current version', @@ -376,7 +379,6 @@ $lang = array_merge($lang, array( 'NEW_FILE' => 'New updated file', 'NO_AUTH_UPDATE' => 'Not authorized to update', - 'NO_DATABASE_UPDATE_NEEDED' => 'All of your files seem to be up to date. Since you are already running the latest version you do not need to update your database.', 'NO_ERRORS' => 'No errors', 'NO_UPDATE_FILES' => 'Not updating the following files', 'NO_UPDATE_FILES_EXPLAIN' => 'The following files are new or modified but the directory they normally reside in could not be found on your installation. If this list contains files to other directories than language/ or styles/ than you may have modified your directory structure and the update may be incomplete.', @@ -391,7 +393,7 @@ $lang = array_merge($lang, array( 'OLD_UPDATE_FILES' => 'Update files are out of date. The update files found are for updating from phpBB %1$s to phpBB %2$s but the latest version of phpBB is %3$s.', 'PERFORM_DATABASE_UPDATE' => 'Perform database update', - 'PERFORM_DATABASE_UPDATE_EXPLAIN' => 'Below you will find a link to the database update script. This script needs to be run seperatly because updating the database might result in unexpected behaviour if you are logged in. The database update can take a while, so please do not stop the execution if it only seems to hang. After you clicked the link and the update finished you can close this window too.', + 'PERFORM_DATABASE_UPDATE_EXPLAIN' => 'Below you will find a link to the database update script. This script needs to be run seperatly because updating the database might result in unexpected behaviour if you are logged in. The database update can take a while, so please do not stop the execution if it seems to hang. After you performed the database update, close the database update window and continue the update process.', 'PREVIOUS_VERSION' => 'Previous version', 'PROGRESS' => 'Progress', @@ -423,11 +425,12 @@ $lang = array_merge($lang, array( 'UPDATE_COMPLETED' => 'Update completed', 'UPDATE_DATABASE' => 'Update database', + 'UPDATE_DATABASE_EXPLAIN' => 'Within the next step the database will be updated.', 'UPDATE_DATABASE_SCHEMA' => 'Updating database schema', 'UPDATE_FILES' => 'Update files', 'UPDATE_FILES_NOTICE' => 'Please make sure you have updated your board files too, this file is only updating your database.', 'UPDATE_INSTALLATION' => 'Update phpBB Installation', - 'UPDATE_INSTALLATION_EXPLAIN' => 'With this option, it is possible to update your phpBB installation to the latest version.
During the process all of your files will be checked for their integrity. You are able to review all differences and files before the update.

The file update itself can be done in two different ways.

Manual Update

With this update you only download your personal set of changed files to make sure you do not lose your file modifications you may have done. After you downloaded this package you need to manually upload the files to their correct position under your phpBB root directory. Once done, you are able to do the file check stage again to see if you moved the files to their correct location. If everything is correctly updated you will be forwarded to the database updater.

Automatic Update with FTP

This method is similar to the first one but without the need to download the changed files and uploading them on your own. This will be done for you. In order to use this method you need to know your FTP login details since you will be asked for them. Once finished you will be redirected to the file check again to make sure everything got updated correctly. If so, you will be forwarded to the database updater.', + 'UPDATE_INSTALLATION_EXPLAIN' => 'With this option, it is possible to update your phpBB installation to the latest version.
During the process all of your files will be checked for their integrity. You are able to review all differences and files before the update.

The file update itself can be done in two different ways.

Manual Update

With this update you only download your personal set of changed files to make sure you do not lose your file modifications you may have done. After you downloaded this package you need to manually upload the files to their correct position under your phpBB root directory. Once done, you are able to do the file check stage again to see if you moved the files to their correct location.

Automatic Update with FTP

This method is similar to the first one but without the need to download the changed files and uploading them on your own. This will be done for you. In order to use this method you need to know your FTP login details since you will be asked for them. Once finished you will be redirected to the file check again to make sure everything got updated correctly.

', 'UPDATE_INSTRUCTIONS' => '

Release announcement

@@ -441,17 +444,16 @@ $lang = array_merge($lang, array(

The recommended way of updating your installation only takes the following steps:

-

Once uploaded your board will be offline for normal users.

- Now start the update process by pointing your browser to the install folder.
+

Once uploaded your board will be offline for normal users due to the install directory you uploaded now present.

+ Now start the update process by pointing your browser to the install folder.

- You will then be guided through the update process. The update is complete after the database update script has been completed successfully - this is the last step within the update process. + You will then be guided through the update process. You will be notified after the update is complete.

- ', 'UPDATE_METHOD' => 'Update method', 'UPDATE_METHOD_EXPLAIN' => 'You are now able to choose your preferred update method. Using the FTP Upload will present you with a form you need to enter your FTP account details into. With this method the files will be automatically moved to the new location and backups of the old files being created by appending .bak to the filename. If you choose to download the modified files you are able to unpack and upload them to their correct location manually later.', @@ -463,6 +465,8 @@ $lang = array_merge($lang, array( 'UPDATED_VERSION' => 'Updated version', 'UPLOAD_METHOD' => 'Upload method', + 'UPDATE_DB_SUCCESS' => 'Database update was successful', + 'VERSION_CHECK' => 'Version Check', 'VERSION_CHECK_EXPLAIN' => 'Checks to see if the version of phpBB you are currently running is up to date.', 'VERSION_NOT_UP_TO_DATE' => 'Your version of phpBB is not up to date. Please continue the update process.',