diff options
author | Dhruv <dhruv.goel92@gmail.com> | 2013-08-08 13:56:39 +0530 |
---|---|---|
committer | Dhruv <dhruv.goel92@gmail.com> | 2013-08-08 13:56:39 +0530 |
commit | f35d732f40181a033e5ecd4e48fc846a82a73955 (patch) | |
tree | 7ca90c3fbe3a7702584f3c105745e58b275eebc4 | |
parent | 08a6bd2218e050ef2e82e644416a725b2a6cca99 (diff) | |
parent | 32499c8808bb72812f66ba00e35c5af128a4d4e2 (diff) | |
download | forums-f35d732f40181a033e5ecd4e48fc846a82a73955.tar forums-f35d732f40181a033e5ecd4e48fc846a82a73955.tar.gz forums-f35d732f40181a033e5ecd4e48fc846a82a73955.tar.bz2 forums-f35d732f40181a033e5ecd4e48fc846a82a73955.tar.xz forums-f35d732f40181a033e5ecd4e48fc846a82a73955.zip |
Merge remote-tracking branch 'nickvergessen/ticket/11574' into develop
# By Joas Schilling (16) and Igor Wiedler (6)
# Via Joas Schilling (5) and Igor Wiedler (2)
* nickvergessen/ticket/11574: (22 commits)
[ticket/11574] Remove install/udpate/new/ fallback from database_update.php
[ticket/11574] Do not display incompatible package note after successful update
[ticket/11574] Remove old "continue step"-message
[ticket/11574] Change order of files and database update
[ticket/11574] Fix more issues in the updater
[ticket/11574] Add trailing slash for consistency
[ticket/11574] Fix table prefix in database updater
[ticket/11574] Fix various path issues in the updater
[ticket/11574] Make install language filename less crazy
[ticket/11574] Use alternate DI config file for updater
[ticket/11574] Include normalizer so it loads form the correct directory
[ticket/11574] Only fall back to install/update versions, when IN_INSTALL ;)
[ticket/11574] Use log object instead of old function
[ticket/11574] Include vendor into update packages
[ticket/11574] Create phpbb_log object before using it.
[ticket/11574] Add correct language parameter to return links
[ticket/11574] Use request object rather then request_var function
[ticket/11574] Load new language files whenever possible
[ticket/11574] Require new files in install/index.php and add a class loader
[ticket/11574] Require new files in database_update.php and add a class loader
...
-rwxr-xr-x | build/package.php | 2 | ||||
-rw-r--r-- | phpBB/adm/style/install_update.html | 55 | ||||
-rw-r--r-- | phpBB/includes/functions_container.php | 41 | ||||
-rw-r--r-- | phpBB/install/database_update.php | 33 | ||||
-rw-r--r-- | phpBB/install/index.php | 68 | ||||
-rw-r--r-- | phpBB/install/install_update.php | 83 | ||||
-rw-r--r-- | phpBB/language/en/install.php | 8 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/di/extension/core.php | 12 | ||||
-rw-r--r-- | phpBB/phpbb/user.php | 7 | ||||
-rw-r--r-- | tests/di/create_container_test.php | 6 |
11 files changed, 174 insertions, 143 deletions
diff --git a/build/package.php b/build/package.php index 48f42b3572..eef6765af6 100755 --- a/build/package.php +++ b/build/package.php @@ -121,6 +121,7 @@ if (sizeof($package->old_packages)) $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/docs ' . $dest_filename_dir); $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/install ' . $dest_filename_dir); + $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/vendor ' . $dest_filename_dir); $package->run_command('mkdir ' . $dest_filename_dir . '/install/update'); $package->run_command('mkdir ' . $dest_filename_dir . '/install/update/old'); @@ -256,6 +257,7 @@ $update_info = array( // Copy the install files to their respective locations $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/docs ' . $package->get('patch_directory')); $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/install ' . $package->get('patch_directory')); + $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/vendor ' . $package->get('patch_directory')); // Remove some files chdir($package->get('patch_directory') . '/install'); diff --git a/phpBB/adm/style/install_update.html b/phpBB/adm/style/install_update.html index b5fa46dbf6..57e2c8ffea 100644 --- a/phpBB/adm/style/install_update.html +++ b/phpBB/adm/style/install_update.html @@ -109,27 +109,14 @@ <!-- ENDIF --> </fieldset> - <!-- IF not S_UP_TO_DATE --> - - <form id="install_dbupdate" method="post" action="{U_DB_UPDATE_ACTION}"> - - <fieldset class="submit-buttons"> - <p>{L_UPDATE_DATABASE_EXPLAIN}</p> - <input class="button1" type="submit" name="db_update" value="{L_UPDATE_DATABASE}" /> - </fieldset> - - </form> - - <!-- ELSE --> - <form id="install_update" method="post" action="{U_ACTION}"> + <form id="install_update" method="post" action="{U_ACTION}"> - <fieldset class="submit-buttons"> - <p>{L_CHECK_FILES_UP_TO_DATE}</p> - <input class="button1" type="submit" name="submit" value="{L_CHECK_FILES}" /> - </fieldset> + <fieldset class="submit-buttons"> + <p>{L_CHECK_FILES_EXPLAIN}</p> + <input class="button1" type="submit" name="submit" value="{L_CHECK_FILES}" /> + </fieldset> - </form> - <!-- ENDIF --> + </form> <!-- ELSEIF S_DB_UPDATE --> @@ -155,29 +142,29 @@ <!-- ELSE --> - <h1>{L_UPDATE_DB_SUCCESS}</h1> + <div class="successbox"> + <h3>{L_UPDATE_SUCCESS}</h3> + <p>{L_EVERYTHING_UP_TO_DATE}</p> + </div> - <br /><br /> + <!-- ENDIF --> - <form id="install_update" method="post" action="{U_ACTION}"> +<!-- ELSEIF S_FILE_CHECK --> - <fieldset class="submit-buttons"> - <p>{L_CHECK_FILES_EXPLAIN}</p> - <input class="button1" type="submit" name="submit" value="{L_CHECK_FILES}" /> - </fieldset> + <!-- IF S_ALL_UP_TO_DATE --> - </form> + <h1>{L_UPDATE_FILE_SUCCESS}</h1> + <p>{L_ALL_FILES_UP_TO_DATE}</p> - <!-- ENDIF --> + <p>{L_UPDATE_DATABASE_EXPLAIN}</p> -<!-- ELSEIF S_FILE_CHECK --> + <form id="install_dbupdate" method="post" action="{U_DB_UPDATE_ACTION}"> - <!-- IF S_ALL_UP_TO_DATE --> + <fieldset class="submit-buttons"> + <input class="button1" type="submit" name="db_update" value="{L_UPDATE_DATABASE}" /> + </fieldset> - <div class="successbox"> - <h3>{L_UPDATE_SUCCESS}</h3> - <p>{L_ALL_FILES_UP_TO_DATE}</p> - </div> + </form> <!-- ELSE --> <h1>{L_COLLECTED_INFORMATION}</h1> diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php index f63dde0614..7cbfa17a0e 100644 --- a/phpBB/includes/functions_container.php +++ b/phpBB/includes/functions_container.php @@ -118,7 +118,10 @@ function phpbb_create_container(array $extensions, $phpbb_root_path, $php_ext) */ function phpbb_create_install_container($phpbb_root_path, $php_ext) { - $core = new phpbb_di_extension_core($phpbb_root_path); + $other_config_path = $phpbb_root_path . 'install/update/new/config/'; + $config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; + + $core = new phpbb_di_extension_core($config_path); $container = phpbb_create_container(array($core), $phpbb_root_path, $php_ext); $container->setParameter('core.root_path', $phpbb_root_path); @@ -136,6 +139,32 @@ function phpbb_create_install_container($phpbb_root_path, $php_ext) } /** +* Create updater container +* +* @param string $phpbb_root_path Root path +* @param string $php_ext PHP Extension +* @param array $config_path Path to config directory +* @return ContainerBuilder object (compiled) +*/ +function phpbb_create_update_container($phpbb_root_path, $php_ext, $config_path) +{ + $config_file = $phpbb_root_path . 'config.' . $php_ext; + return phpbb_create_compiled_container( + $config_file, + array( + new phpbb_di_extension_config($config_file), + new phpbb_di_extension_core($config_path), + ), + array( + new phpbb_di_pass_collection_pass(), + new phpbb_di_pass_kernel_pass(), + ), + $phpbb_root_path, + $php_ext + ); +} + +/** * Create a compiled ContainerBuilder object * * @param array $extensions Array of Container extension objects @@ -146,11 +175,6 @@ function phpbb_create_install_container($phpbb_root_path, $php_ext) */ function phpbb_create_compiled_container($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) { - $installed_exts = phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path); - - // Now pass the enabled extension paths into the ext compiler extension - $extensions[] = new phpbb_di_extension_ext($installed_exts); - // Create the final container to be compiled and cached $container = phpbb_create_container($extensions, $phpbb_root_path, $php_ext); @@ -231,11 +255,14 @@ function phpbb_create_dumped_container_unless_debug($config_file, array $extensi function phpbb_create_default_container($phpbb_root_path, $php_ext) { $config_file = $phpbb_root_path . 'config.' . $php_ext; + $installed_exts = phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path); + return phpbb_create_dumped_container_unless_debug( $config_file, array( new phpbb_di_extension_config($config_file), - new phpbb_di_extension_core($phpbb_root_path), + new phpbb_di_extension_core($phpbb_root_path . 'config'), + new phpbb_di_extension_ext($installed_exts), ), array( new phpbb_di_pass_collection_pass(), diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index cd6fb7931b..3be5ea659c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -21,26 +21,6 @@ define('IN_INSTALL', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); -if (!function_exists('phpbb_require_updated')) -{ - function phpbb_require_updated($path, $optional = false) - { - global $phpbb_root_path; - - $new_path = $phpbb_root_path . 'install/update/new/' . $path; - $old_path = $phpbb_root_path . $path; - - if (file_exists($new_path)) - { - require($new_path); - } - else if (!$optional || file_exists($old_path)) - { - require($old_path); - } - } -} - function phpbb_end_update($cache, $config) { $cache->purge(); @@ -69,7 +49,7 @@ function phpbb_end_update($cache, $config) exit_handler(); } -phpbb_require_updated('includes/startup.' . $phpEx); +require($phpbb_root_path . 'includes/startup.' . $phpEx); include($phpbb_root_path . 'config.' . $phpEx); if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) @@ -88,7 +68,9 @@ require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); require($phpbb_root_path . 'includes/functions_container.' . $phpEx); +require($phpbb_root_path . 'config.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); +include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours @@ -101,11 +83,10 @@ $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) $container_extensions = array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), - new phpbb_di_extension_core($phpbb_root_path), + new phpbb_di_extension_core($phpbb_root_path . 'config/'), ); $container_passes = array( new phpbb_di_pass_collection_pass(), - //new phpbb_di_pass_kernel_pass(), ); $phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); @@ -263,8 +244,8 @@ while (!$migrator->finished()) // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $update_start_time) >= $safe_time_limit) { - echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '<br />'; - echo '<a href="' . append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=' . $request->variable('type', 0) . '&language=' . $user->lang['USER_LANG']) . '">' . $user->lang['DATABASE_UPDATE_CONTINUE'] . '</a>'; + echo '<br />' . $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '<br /><br />'; + echo '<a href="' . append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=' . $request->variable('type', 0) . '&language=' . $request->variable('language', 'en')) . '" class="button1">' . $user->lang['DATABASE_UPDATE_CONTINUE'] . '</a>'; phpbb_end_update($cache, $config); } @@ -280,7 +261,7 @@ echo $user->lang['DATABASE_UPDATE_COMPLETE'] . '<br />'; if ($request->variable('type', 0)) { echo $user->lang['INLINE_UPDATE_SUCCESSFUL'] . '<br /><br />'; - echo '<a href="' . append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update&sub=file_check&language=' . $user->lang['USER_LANG']) . '" class="button1">' . $user->lang['CONTINUE_UPDATE_NOW'] . '</a>'; + echo '<a href="' . append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update&sub=update_db&language=' . $request->variable('language', 'en')) . '" class="button1">' . $user->lang['CONTINUE_UPDATE_NOW'] . '</a>'; } else { diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 45e5777e36..bd39e231f4 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -28,7 +28,7 @@ if (version_compare(PHP_VERSION, '5.3.3') < 0) function phpbb_require_updated($path, $optional = false) { - global $phpbb_root_path; + global $phpbb_root_path, $table_prefix; $new_path = $phpbb_root_path . 'install/update/new/' . $path; $old_path = $phpbb_root_path . $path; @@ -43,6 +43,23 @@ function phpbb_require_updated($path, $optional = false) } } +function phpbb_include_updated($path, $optional = false) +{ + global $phpbb_root_path; + + $new_path = $phpbb_root_path . 'install/update/new/' . $path; + $old_path = $phpbb_root_path . $path; + + if (file_exists($new_path)) + { + include($new_path); + } + else if (!$optional || file_exists($old_path)) + { + include($old_path); + } +} + phpbb_require_updated('includes/startup.' . $phpEx); // Try to override some limits - maybe it helps some... @@ -78,18 +95,21 @@ $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relati $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include essential scripts -require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); +phpbb_require_updated('phpbb/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/functions.' . $phpEx); -require($phpbb_root_path . 'includes/functions_container.' . $phpEx); +phpbb_require_updated('includes/functions.' . $phpEx); +phpbb_require_updated('includes/functions_container.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx, true); -include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); -include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); -require($phpbb_root_path . 'includes/functions_install.' . $phpEx); +phpbb_include_updated('includes/functions_admin.' . $phpEx); +phpbb_include_updated('includes/utf/utf_normalizer.' . $phpEx); +phpbb_include_updated('includes/utf/utf_tools.' . $phpEx); +phpbb_require_updated('includes/functions_install.' . $phpEx); // Setup class loader first +$phpbb_class_loader_new = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx); +$phpbb_class_loader_new->register(); $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", $phpEx); @@ -108,7 +128,7 @@ $request = $phpbb_container->get('request'); request_var('', 0, false, false, $request); // "dependency injection" for a function // Try and load an appropriate language if required -$language = basename(request_var('language', '')); +$language = basename($request->variable('language', '')); if ($request->header('Accept-Language') && !$language) { @@ -167,11 +187,23 @@ if (!file_exists($phpbb_root_path . 'language/' . $language) || !is_dir($phpbb_r } // And finally, load the relevant language files -include($phpbb_root_path . 'language/' . $language . '/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/acp/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/acp/board.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/posting.' . $phpEx); +$load_lang_files = array('common', 'acp/common', 'acp/board', 'install', 'posting'); +$new_path = $phpbb_root_path . 'install/update/new/language/' . $language . '/'; +$old_path = $phpbb_root_path . 'language/' . $language . '/'; + +// NOTE: we can not use "phpbb_include_updated" as the files uses vars which would be required +// to be global while loading. +foreach ($load_lang_files as $lang_file) +{ + if (file_exists($new_path . $lang_file . '.' . $phpEx)) + { + include($new_path . $lang_file . '.' . $phpEx); + } + else + { + include($old_path . $lang_file . '.' . $phpEx); + } +} // usually we would need every single constant here - and it would be consistent. For 3.0.x, use a dirty hack... :( @@ -181,8 +213,8 @@ define('CHMOD_READ', 4); define('CHMOD_WRITE', 2); define('CHMOD_EXECUTE', 1); -$mode = request_var('mode', 'overview'); -$sub = request_var('sub', ''); +$mode = $request->variable('mode', 'overview'); +$sub = $request->variable('sub', ''); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); @@ -217,7 +249,11 @@ $phpbb_style_path_provider = new phpbb_style_path_provider(); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); $phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); $phpbb_style->set_ext_dir_prefix('adm/'); -$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); + +$paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style'); +$paths = array_filter($paths, 'is_dir'); +$phpbb_style->set_custom_style('admin', $paths, array(), ''); + $template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 0cd203eda8..4ae39f202f 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -39,7 +39,7 @@ if (!empty($setmodules)) 'module_filename' => substr(basename(__FILE__), 0, -strlen($phpEx)-1), 'module_order' => 30, 'module_subs' => '', - 'module_stages' => array('INTRO', 'VERSION_CHECK', 'UPDATE_DB', 'FILE_CHECK', 'UPDATE_FILES'), + 'module_stages' => array('INTRO', 'VERSION_CHECK', 'FILE_CHECK', 'UPDATE_FILES', 'UPDATE_DB'), 'module_reqs' => '' ); } @@ -73,8 +73,13 @@ class install_update extends module global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container; + // We must enable super globals, otherwise creating a new instance of the request class, + // using the new container with a dbal connection will fail with the following PHP Notice: + // Object of class phpbb_request_deactivated_super_global could not be converted to int + $request->enable_super_globals(); + // Create a normal container now - $phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx); + $phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, $phpbb_root_path . 'install/update/new/config'); // Writes into global $cache $cache = $phpbb_container->get('cache'); @@ -123,7 +128,7 @@ class install_update extends module $config['default_lang'] = $language; $user->data['user_lang'] = $language; - $user->setup(array('common', 'acp/common', 'acp/board', 'install', 'posting')); + $user->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting')); // Reset the default_lang $config['default_lang'] = $config_default_lang; @@ -136,7 +141,9 @@ class install_update extends module } // Set custom template again. ;) - $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); + $paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style'); + $paths = array_filter($paths, 'is_dir'); + $phpbb_style->set_custom_style('admin', $paths, array(), ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], @@ -216,12 +223,6 @@ class install_update extends module if ($this->test_update === false) { - // 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($phpbb_adm_relative_path . '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/' . $language . '/install.' . $phpEx, $this->update_info['files'])) { @@ -274,15 +275,14 @@ class install_update extends module $this->page_title = 'STAGE_VERSION_CHECK'; $template->assign_vars(array( - 'S_UP_TO_DATE' => $up_to_date, 'S_VERSION_CHECK' => true, - 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), - 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_db"), + 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), + 'S_UP_TO_DATE' => $up_to_date, 'LATEST_VERSION' => $this->latest_version, - 'CURRENT_VERSION' => $this->current_version) - ); + 'CURRENT_VERSION' => $this->current_version, + )); // Print out version the update package updates to if ($this->latest_version != $this->update_info['version']['to']) @@ -303,30 +303,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->update_info['version']['to']) - { - $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, @@ -334,8 +310,14 @@ class install_update extends module 'U_DB_UPDATE' => append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=1&language=' . $user->data['user_lang']), 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_db"), 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), + 'L_EVERYTHING_UP_TO_DATE' => $user->lang('EVERYTHING_UP_TO_DATE', append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&redirect=' . $phpbb_adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics')), )); + // Do not display incompatible package note after successful update + if ($config['version'] == $this->update_info['version']['to']) + { + $template->assign_var('S_ERROR', false); + } break; case 'file_check': @@ -501,17 +483,30 @@ class install_update extends module $template->assign_vars(array( 'S_FILE_CHECK' => true, 'S_ALL_UP_TO_DATE' => $all_up_to_date, - 'L_ALL_FILES_UP_TO_DATE' => $user->lang('ALL_FILES_UP_TO_DATE', append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&redirect=' . $phpbb_adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics')), 'S_VERSION_UP_TO_DATE' => $up_to_date, + 'S_UP_TO_DATE' => $up_to_date, 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), 'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_files"), 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_db"), )); + // Since some people try to update to RC releases, but phpBB.com tells them the last version is the version they currently run + // we are faced with the updater thinking the database schema is up-to-date; which it is, but should be updated none-the-less + // We now try to cope with this by triggering the update process + if (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->update_info['version']['to'])), '<')) + { + $template->assign_vars(array( + 'S_UP_TO_DATE' => false, + )); + } + if ($all_up_to_date) { + global $phpbb_container; + $phpbb_log = $phpbb_container->get('log'); + // Add database update to log - add_log('admin', 'LOG_UPDATE_PHPBB', $this->current_version, $this->update_to_version); + $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_UPDATE_PHPBB', time(), array($this->current_version, $this->update_to_version)); $db->sql_return_on_error(true); $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); @@ -1090,12 +1085,6 @@ class install_update extends module $this->tpl_name = 'install_update_diff'; - // Got the diff template itself updated? If so, we are able to directly use it - if (in_array($phpbb_adm_relative_path . 'style/install_update_diff.html', $this->update_info['files'])) - { - $this->tpl_name = '../../install/update/new/adm/style/install_update_diff'; - } - $this->page_title = 'VIEWING_FILE_DIFF'; $status = request_var('status', ''); diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index be45047861..03c9562983 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -374,7 +374,7 @@ $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 should now <a href="%1$s">login to your board</a> and check if everything is working fine. Do not forget to delete, rename or move your install directory! Please send us updated information about your server and board configurations from the <a href="%2$s">Send statistics</a> module in your ACP.', + 'ALL_FILES_UP_TO_DATE' => 'All files are up to date with the latest phpBB version.', 'ARCHIVE_FILE' => 'Source file within archive', 'BACK' => 'Back', @@ -398,7 +398,7 @@ $lang = array_merge($lang, array( 'DATABASE_TYPE' => 'Database type', 'DATABASE_UPDATE_COMPLETE' => 'Database updater has completed!', - 'DATABASE_UPDATE_CONTINUE' => 'Continue database update.', + 'DATABASE_UPDATE_CONTINUE' => 'Continue database update', 'DATABASE_UPDATE_INFO_OLD' => 'The database update file within the install directory is outdated. Please make sure you uploaded the correct version of the file.', 'DATABASE_UPDATE_NOT_COMPLETED' => 'The database update has not yet completed.', 'DELETE_USER_REMOVE' => 'Delete user and remove posts', @@ -419,8 +419,9 @@ $lang = array_merge($lang, array( 'DOWNLOAD_UPDATE_METHOD' => 'Download modified files archive', 'DOWNLOAD_UPDATE_METHOD_EXPLAIN' => 'Once downloaded you should unpack the archive. You will find the modified files you need to upload to your phpBB root directory within it. Please upload the files to their respective locations then. After you have uploaded all files, please check the files again with the other button below.', - 'ERROR' => 'Error', 'EDIT_USERNAME' => 'Edit username', + 'ERROR' => 'Error', + 'EVERYTHING_UP_TO_DATE' => 'Everything is up to date with the latest phpBB version. You should now <a href="%1$s">login to your board</a> and check if everything is working fine. Do not forget to delete, rename or move your install directory! Please send us updated information about your server and board configurations from the <a href="%2$s">Send statistics</a> module in your ACP.', 'FILE_ALREADY_UP_TO_DATE' => 'File is already up to date.', 'FILE_DIFF_NOT_ALLOWED' => 'File not allowed to be diffed.', @@ -570,6 +571,7 @@ $lang = array_merge($lang, array( 'UPLOAD_METHOD' => 'Upload method', 'UPDATE_DB_SUCCESS' => 'Database update was successful.', + 'UPDATE_FILE_SUCCESS' => 'File update was successful.', 'USER_ACTIVE' => 'Active user', 'USER_INACTIVE' => 'Inactive user', diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php index 97331e9bb2..1338d48006 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php @@ -108,7 +108,7 @@ class phpbb_db_migration_data_30x_3_0_12_rc1 extends phpbb_db_migration WHERE user_id = $bot_user_id"; $this->sql_query($sql); - user_delete('remove', $bot_user_id); + user_delete('retain', $bot_user_id); } else { diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index 9c36ba2fc4..9d59a24b7e 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -26,19 +26,19 @@ use Symfony\Component\Config\FileLocator; class phpbb_di_extension_core extends Extension { /** - * phpBB Root path + * Config path * @var string */ - protected $root_path; + protected $config_path; /** * Constructor * - * @param string $root_path Root path + * @param string $config_path Config path */ - public function __construct($root_path) + public function __construct($config_path) { - $this->root_path = $root_path; + $this->config_path = $config_path; } /** @@ -51,7 +51,7 @@ class phpbb_di_extension_core extends Extension */ public function load(array $config, ContainerBuilder $container) { - $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->root_path . 'config'))); + $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path))); $loader->load('services.yml'); } diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index 5530fe3f03..b39438e315 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -590,6 +590,13 @@ class phpbb_user extends phpbb_session $language_filename = $lang_path . $this->lang_name . '/' . $filename . '.' . $phpEx; } + // If we are in install, try to use the updated version, when available + $install_language_filename = str_replace('language/', 'install/update/new/language/', $language_filename); + if (defined('IN_INSTALL') && file_exists($install_language_filename)) + { + $language_filename = $install_language_filename; + } + if (!file_exists($language_filename)) { global $config; diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index b3992dbd80..c570f19ebd 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -17,7 +17,7 @@ class phpbb_di_container_test extends phpbb_test_case $phpbb_root_path = __DIR__ . '/../../phpBB/'; $extensions = array( new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'), - new phpbb_di_extension_core($phpbb_root_path), + new phpbb_di_extension_core($phpbb_root_path . 'config'), ); $container = phpbb_create_container($extensions, $phpbb_root_path, 'php'); @@ -29,7 +29,7 @@ class phpbb_di_container_test extends phpbb_test_case $phpbb_root_path = __DIR__ . '/../../phpBB/'; $extensions = array( new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'), - new phpbb_di_extension_core($phpbb_root_path), + new phpbb_di_extension_core($phpbb_root_path . 'config'), ); $container = phpbb_create_install_container($phpbb_root_path, 'php'); @@ -43,7 +43,7 @@ class phpbb_di_container_test extends phpbb_test_case $config_file = __DIR__ . '/fixtures/config.php'; $extensions = array( new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'), - new phpbb_di_extension_core($phpbb_root_path), + new phpbb_di_extension_core($phpbb_root_path . 'config'), ); $container = phpbb_create_compiled_container($config_file, $extensions, array(), $phpbb_root_path, 'php'); |