mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
Merge pull request #1853 from nickvergessen/ticket/11927
[ticket/11927] Correctly add new files on update
This commit is contained in:
commit
d69f35d450
3 changed files with 88 additions and 1 deletions
|
@ -533,3 +533,51 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_test
|
||||||
|
|
||||||
return $config_data;
|
return $config_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether a file should be ignored on update
|
||||||
|
*
|
||||||
|
* We ignore new files in some circumstances:
|
||||||
|
* 1. The file is a language file, but the language is not installed
|
||||||
|
* 2. The file is a style file, but the style is not installed
|
||||||
|
* 3. The file is a style language file, but the language is not installed
|
||||||
|
*
|
||||||
|
* @param string $phpbb_root_path phpBB root path
|
||||||
|
* @param string $file File including path from phpbb root
|
||||||
|
* @return bool Should we ignore the new file or add it to the board?
|
||||||
|
*/
|
||||||
|
function phpbb_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;
|
||||||
|
}
|
||||||
|
|
|
@ -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 (!phpbb_ignore_new_file_on_update($phpbb_root_path, $file))
|
||||||
{
|
{
|
||||||
$this->get_custom_info($update_list['new'], $file);
|
$this->get_custom_info($update_list['new'], $file);
|
||||||
$update_list['new'][] = array('filename' => $file, 'custom' => false);
|
$update_list['new'][] = array('filename' => $file, 'custom' => false);
|
||||||
|
|
39
tests/functions_install/ignore_new_file_on_update_test.php
Normal file
39
tests/functions_install/ignore_new_file_on_update_test.php
Normal file
|
@ -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, phpbb_ignore_new_file_on_update($phpbb_root_path, $file));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue