diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-11-07 12:56:10 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-11-07 13:12:58 +0100 |
commit | 7aa4d8fce2e61776d5f2dbf67386a589bcd7d634 (patch) | |
tree | 8b881f3eda39fa86d045561cf7bda01c872d9fda | |
parent | cc54e6a9e58cb57fad87fc5b17e3c885531bc4e6 (diff) | |
download | forums-7aa4d8fce2e61776d5f2dbf67386a589bcd7d634.tar forums-7aa4d8fce2e61776d5f2dbf67386a589bcd7d634.tar.gz forums-7aa4d8fce2e61776d5f2dbf67386a589bcd7d634.tar.bz2 forums-7aa4d8fce2e61776d5f2dbf67386a589bcd7d634.tar.xz forums-7aa4d8fce2e61776d5f2dbf67386a589bcd7d634.zip |
[ticket/11927] Correctly add new files on update
Currently we ignore language and style files when the directory where they
go to do not exist. However in 3.1 we introduce some new sub directories:
* language/en/email/short/
* styles/prosilver/theme/en/
So we need to change our check to look whether the language or style exist,
rather then the parent directory.
PHPBB3-11927
-rw-r--r-- | phpBB/includes/functions_install.php | 39 | ||||
-rw-r--r-- | phpBB/install/install_update.php | 2 | ||||
-rw-r--r-- | tests/functions_install/ignore_new_file_on_update_test.php | 39 |
3 files changed, 79 insertions, 1 deletions
diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 1be6e49471..be0ecd4306 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -533,3 +533,42 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_test return $config_data; } + +/** +* +*/ +function ignore_new_file_on_update($phpbb_root_path, $file) +{ + $ignore_new_file = false; + + // We ignore new files in some circumstances: + // 1. The file is a language file, but the language is not installed + if (!$ignore_new_file && strpos($file, 'language/') === 0) + { + list($language_dir, $language_iso) = explode('/', $file); + $ignore_new_file = !file_exists($phpbb_root_path . $language_dir . '/' . $language_iso); + } + + // 2. The file is a style file, but the style is not installed + if (!$ignore_new_file && strpos($file, 'styles/') === 0) + { + list($styles_dir, $style_name) = explode('/', $file); + $ignore_new_file = !file_exists($phpbb_root_path . $styles_dir . '/' . $style_name); + } + + // 3. The file is a style language file, but the language is not installed + if (!$ignore_new_file && strpos($file, 'styles/') === 0) + { + $dirs = explode('/', $file); + if ($dirs >= 5) + { + list($styles_dir, $style_name, $template_component, $language_iso) = explode('/', $file); + if ($template_component == 'theme' && $language_iso !== 'images') + { + $ignore_new_file = !file_exists($phpbb_root_path . 'language/' . $language_iso); + } + } + } + + return $ignore_new_file; +} diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index b7b358ab2f..67420803c9 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -1311,7 +1311,7 @@ class install_update extends module } }*/ - if (file_exists($phpbb_root_path . dirname($file)) || (strpos($file, 'styles/') !== 0 && strpos($file, 'language/') !== 0)) + if (!ignore_new_file_on_update($phpbb_root_path, $file)) { $this->get_custom_info($update_list['new'], $file); $update_list['new'][] = array('filename' => $file, 'custom' => false); diff --git a/tests/functions_install/ignore_new_file_on_update_test.php b/tests/functions_install/ignore_new_file_on_update_test.php new file mode 100644 index 0000000000..0c05cc6907 --- /dev/null +++ b/tests/functions_install/ignore_new_file_on_update_test.php @@ -0,0 +1,39 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_install.php'; + +class phpbb_functions_install_ignore_new_file_on_update_test extends phpbb_test_case +{ + static public function ignore_new_file_on_update_data() + { + return array( + array('willneverexist.php', false), + array('includes/dirwillneverexist/newfile.php', false), + + array('language/en/email/short/bookmark.txt', false), + array('language/languagewillneverexist/email/short/bookmark.txt', true), + + array('styles/prosilver/template/bbcode.html', false), + array('styles/stylewillneverexist/template/bbcode.html', true), + + array('styles/prosilver/theme/en/icon_user_online.gif', false), + array('styles/prosilver/theme/languagewillneverexist/icon_user_online.gif', true), + ); + } + + /** + * @dataProvider ignore_new_file_on_update_data + */ + public function test_ignore_new_file_on_update($file, $expected) + { + global $phpbb_root_path; + $this->assertEquals($expected, ignore_new_file_on_update($phpbb_root_path, $file)); + } +} |