diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | build/build.xml | 9 | ||||
-rw-r--r-- | phpBB/feed.php | 31 | ||||
-rw-r--r-- | phpBB/includes/db/db_tools.php | 17 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 6 | ||||
-rw-r--r-- | phpBB/includes/functions_content.php | 3 | ||||
-rw-r--r-- | phpBB/includes/functions_display.php | 52 | ||||
-rw-r--r-- | phpBB/includes/session.php | 33 | ||||
-rw-r--r-- | phpBB/index.php | 12 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/editor.js | 11 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/forum_fn.js | 2 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/mcp_front.html | 1 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/memberlist_view.html | 4 | ||||
-rw-r--r-- | phpBB/styles/subsilver2/template/editor.js | 11 | ||||
-rw-r--r-- | phpBB/styles/subsilver2/template/memberlist_view.html | 4 | ||||
-rw-r--r-- | tests/dbal/db_tools_test.php | 60 | ||||
-rw-r--r-- | tests/tmp/.gitkeep (renamed from tests/utf/data/.gitkeep) | 0 | ||||
-rw-r--r-- | tests/utf/normalizer_test.php | 11 |
18 files changed, 204 insertions, 65 deletions
diff --git a/.gitignore b/.gitignore index 65058b2eaf..7d789c59a1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ /phpBB/store/* /tests/phpbb_unit_tests.sqlite2 /tests/test_config.php -/tests/utf/data/*.txt +/tests/tmp/* diff --git a/build/build.xml b/build/build.xml index 7cfb5d0bf8..eb63bde034 100644 --- a/build/build.xml +++ b/build/build.xml @@ -119,6 +119,15 @@ <target name="create-package" depends="prepare-new-version,old-version-diffs"> <exec dir="build" command="php -f package.php '${versions}' > logs/package.log" escape="false" /> <exec dir="build" command="php -f build_diff.php '${prevversion}' '${newversion}' > logs/build_diff.log" escape="false" /> + <exec dir="build" escape="false" + command="diff -crNEBwd old_versions/release-${prevversion}/language new_version/phpBB3/language > + save/save_${prevversion}_to_${newversion}/language/phpbb-${prevversion}_to_${newversion}_language.patch" /> + <exec dir="build" escape="false" + command="diff -crNEBwd old_versions/release-${prevversion}/styles/prosilver new_version/phpBB3/styles/prosilver > + save/save_${prevversion}_to_${newversion}/prosilver/phpbb-${prevversion}_to_${newversion}_prosilver.patch" /> + <exec dir="build" escape="false" + command="diff -crNEBwd old_versions/release-${prevversion}/styles/subsilver2 new_version/phpBB3/styles/subsilver2 > + save/save_${prevversion}_to_${newversion}/subsilver2/phpbb-${prevversion}_to_${newversion}_subsilver2.patch" /> </target> <!-- diff --git a/phpBB/feed.php b/phpBB/feed.php index d737b8e10c..9816f0f303 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -173,6 +173,12 @@ if (defined('DEBUG_EXTRA') && request_var('explain', 0) && $auth->acl_get('a_')) header("Content-Type: application/atom+xml; charset=UTF-8"); header("Last-Modified: " . gmdate('D, d M Y H:i:s', $feed_updated_time) . ' GMT'); +if (!empty($user->data['is_bot'])) +{ + // Let reverse proxies know we detected a bot. + header('X-PHPBB-IS-BOT: yes'); +} + echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; echo '<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="' . $global_vars['FEED_LANG'] . '">' . "\n"; echo '<link rel="self" type="application/atom+xml" href="' . $global_vars['SELF_LINK'] . '" />' . "\n\n"; @@ -604,30 +610,9 @@ class phpbb_feed_base function get_passworded_forums() { - global $db, $user; - - // Exclude passworded forums - $sql = 'SELECT f.forum_id, fa.user_id - FROM ' . FORUMS_TABLE . ' f - LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa - ON (fa.forum_id = f.forum_id - AND fa.session_id = '" . $db->sql_escape($user->session_id) . "') - WHERE f.forum_password <> ''"; - $result = $db->sql_query($sql); - - $forum_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_id = (int) $row['forum_id']; - - if ($row['user_id'] != $user->data['user_id']) - { - $forum_ids[$forum_id] = $forum_id; - } - } - $db->sql_freeresult($result); + global $user; - return $forum_ids; + return $user->get_passworded_forums(); } function get_item() diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index d23323a5b1..2cb0fcef68 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -649,6 +649,23 @@ class phpbb_db_tools $sqlite = true; } + // Drop tables? + if (!empty($schema_changes['drop_tables'])) + { + foreach ($schema_changes['drop_tables'] as $table) + { + // only drop table if it exists + if ($this->sql_table_exists($table)) + { + $result = $this->sql_table_drop($table); + if ($this->return_statements) + { + $statements = array_merge($statements, $result); + } + } + } + } + // Add tables? if (!empty($schema_changes['add_tables'])) { diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c6258588ca..628f8ee123 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4647,6 +4647,12 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 header('Expires: 0'); header('Pragma: no-cache'); + if (!empty($user->data['is_bot'])) + { + // Let reverse proxies know we detected a bot. + header('X-PHPBB-IS-BOT: yes'); + } + return; } diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index b34976db2a..b7650ecd6a 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -691,9 +691,6 @@ function censor_text($text) return ''; } - // Strip control characters - $text = preg_replace('/[\x00-\x0f]/', '', $text); - // We moved the word censor checks in here because we call this function quite often - and then only need to do the check once if (!isset($censors) || !is_array($censors)) { diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 7982b9908d..14d0c44dcf 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -51,6 +51,27 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id']; } + // Handle marking everything read + if ($mark_read == 'all') + { + $redirect = build_url(array('mark', 'hash')); + meta_refresh(3, $redirect); + + if (check_link_hash(request_var('hash', ''), 'global')) + { + markread('all'); + + trigger_error( + $user->lang['FORUMS_MARKED'] . '<br /><br />' . + sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>') + ); + } + else + { + trigger_error(sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>')); + } + } + // Display list of active topics for this category? $show_active = (isset($root_data['forum_flags']) && ($root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) ? true : false; @@ -120,13 +141,14 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_id = $row['forum_id']; // Mark forums read? - if ($mark_read == 'forums' || $mark_read == 'all') + if ($mark_read == 'forums') { if ($auth->acl_get('f_list', $forum_id)) { $forum_ids[] = $forum_id; - continue; } + + continue; } // Category with no members @@ -152,8 +174,6 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod continue; } - $forum_ids[] = $forum_id; - if ($config['load_db_lastread'] && $user->data['is_registered']) { $forum_tracking_info[$forum_id] = (!empty($row['mark_time'])) ? $row['mark_time'] : $user->data['user_lastmark']; @@ -255,24 +275,16 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $db->sql_freeresult($result); // Handle marking posts - if ($mark_read == 'forums' || $mark_read == 'all') + if ($mark_read == 'forums') { $redirect = build_url(array('mark', 'hash')); $token = request_var('hash', ''); if (check_link_hash($token, 'global')) { - if ($mark_read == 'all') - { - markread('all'); - $message = sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>'); - } - else - { - // Add 0 to forums array to mark global announcements correctly - $forum_ids[] = 0; - markread('topics', $forum_ids); - $message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>'); - } + // Add 0 to forums array to mark global announcements correctly + $forum_ids[] = 0; + markread('topics', $forum_ids); + $message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>'); meta_refresh(3, $redirect); trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message); } @@ -996,13 +1008,17 @@ function display_user_activity(&$userdata) } // Obtain active topic + // We need to exclude passworded forums here so we do not leak the topic title + $forum_ary_topic = array_unique(array_merge($forum_ary, $user->get_passworded_forums())); + $forum_sql_topic = (!empty($forum_ary_topic)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary_topic, true) : ''; + $sql = 'SELECT topic_id, COUNT(post_id) AS num_posts FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $userdata['user_id'] . " AND post_postcount = 1 AND (post_approved = 1 $sql_m_approve) - $forum_sql + $forum_sql_topic GROUP BY topic_id ORDER BY num_posts DESC"; $result = $db->sql_query_limit($sql, 1); diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index e9e706e2b8..caadcbafaa 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -2410,6 +2410,39 @@ class user extends session return true; } + + /** + * Returns all password protected forum ids the user is currently NOT authenticated for. + * + * @return array Array of forum ids + * @access public + */ + function get_passworded_forums() + { + global $db; + + $sql = 'SELECT f.forum_id, fa.user_id + FROM ' . FORUMS_TABLE . ' f + LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa + ON (fa.forum_id = f.forum_id + AND fa.session_id = '" . $db->sql_escape($this->session_id) . "') + WHERE f.forum_password <> ''"; + $result = $db->sql_query($sql); + + $forum_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $forum_id = (int) $row['forum_id']; + + if ($row['user_id'] != $this->data['user_id']) + { + $forum_ids[$forum_id] = $forum_id; + } + } + $db->sql_freeresult($result); + + return $forum_ids; + } } ?>
\ No newline at end of file diff --git a/phpBB/index.php b/phpBB/index.php index 91cbd326b9..0105a0a1bd 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -81,15 +81,23 @@ $legend = implode(', ', $legend); // Generate birthday list if required ... $birthday_list = ''; -if ($config['load_birthdays'] && $config['allow_birthdays']) +if ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel')) { $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst); + + // Display birthdays of 29th february on 28th february in non-leap-years + $leap_year_birthdays = ''; + if ($now['mday'] == 28 && $now['mon'] == 2 && !$user->format_date(time(), 'L')) + { + $leap_year_birthdays = " OR user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'"; + } + $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday FROM ' . USERS_TABLE . ' u LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid) WHERE (b.ban_id IS NULL OR b.ban_exclude = 1) - AND u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' + AND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' $leap_year_birthdays) AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')'; $result = $db->sql_query($sql); diff --git a/phpBB/styles/prosilver/template/editor.js b/phpBB/styles/prosilver/template/editor.js index ddc862bb8c..cfdb54f54b 100644 --- a/phpBB/styles/prosilver/template/editor.js +++ b/phpBB/styles/prosilver/template/editor.js @@ -151,8 +151,10 @@ function insert_text(text, spaces, popup) { text = ' ' + text + ' '; } - - if (!isNaN(textarea.selectionStart)) + + // Since IE9, IE also has textarea.selectionStart, but it still needs to be treated the old way. + // Therefore we simply add a !is_ie here until IE fixes the text-selection completely. + if (!isNaN(textarea.selectionStart) && !is_ie) { var sel_start = textarea.selectionStart; var sel_end = textarea.selectionEnd; @@ -216,11 +218,12 @@ function addquote(post_id, username, l_wrote) } // Get text selection - not only the post content :( - if (window.getSelection) + // IE9 must use the document.selection method but has the *.getSelection so we just force no IE + if (window.getSelection && !is_ie) { theSelection = window.getSelection().toString(); } - else if (document.getSelection) + else if (document.getSelection && !is_ie) { theSelection = document.getSelection(); } diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 4a85858df5..240fe7e51d 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -200,7 +200,7 @@ function selectCode(a) // Get ID of code block var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; - // Not IE + // Not IE and IE9+ if (window.getSelection) { var s = window.getSelection(); diff --git a/phpBB/styles/prosilver/template/mcp_front.html b/phpBB/styles/prosilver/template/mcp_front.html index 0891948fb6..b71d120ed6 100644 --- a/phpBB/styles/prosilver/template/mcp_front.html +++ b/phpBB/styles/prosilver/template/mcp_front.html @@ -28,7 +28,6 @@ <dl> <dt> <a href="{unapproved.U_POST_DETAILS}" class="topictitle">{unapproved.SUBJECT}</a> {unapproved.ATTACH_ICON_IMG}<br /> - <!-- IF report.PAGINATION --><strong class="pagination"><span>{report.PAGINATION}</span></strong><!-- ENDIF --> {L_POSTED} {L_POST_BY_AUTHOR} {unapproved.AUTHOR_FULL} » {unapproved.POST_TIME} </dt> <dd class="moderation"><span> diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index 3398bb5e9e..cfec07cff0 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -89,8 +89,8 @@ <!-- IF POSTS_IN_QUEUE and U_MCP_QUEUE --><br />(<a href="{U_MCP_QUEUE}">{L_POSTS_IN_QUEUE}</a>)<!-- ELSEIF POSTS_IN_QUEUE --><br />({L_POSTS_IN_QUEUE})<!-- ENDIF --> </dd> <!-- IF S_SHOW_ACTIVITY and POSTS --> - <dt>{L_ACTIVE_IN_FORUM}:</dt> <dd><!-- IF ACTIVE_FORUM --><strong><a href="{U_ACTIVE_FORUM}">{ACTIVE_FORUM}</a></strong><br />({ACTIVE_FORUM_POSTS} / {ACTIVE_FORUM_PCT})<!-- ELSE --> - <!-- ENDIF --></dd> - <dt>{L_ACTIVE_IN_TOPIC}:</dt> <dd><!-- IF ACTIVE_TOPIC --><strong><a href="{U_ACTIVE_TOPIC}">{ACTIVE_TOPIC}</a></strong><br />({ACTIVE_TOPIC_POSTS} / {ACTIVE_TOPIC_PCT})<!-- ELSE --> - <!-- ENDIF --></dd> + <dt>{L_ACTIVE_IN_FORUM}:</dt> <dd><!-- IF ACTIVE_FORUM != '' --><strong><a href="{U_ACTIVE_FORUM}">{ACTIVE_FORUM}</a></strong><br />({ACTIVE_FORUM_POSTS} / {ACTIVE_FORUM_PCT})<!-- ELSE --> - <!-- ENDIF --></dd> + <dt>{L_ACTIVE_IN_TOPIC}:</dt> <dd><!-- IF ACTIVE_TOPIC != '' --><strong><a href="{U_ACTIVE_TOPIC}">{ACTIVE_TOPIC}</a></strong><br />({ACTIVE_TOPIC_POSTS} / {ACTIVE_TOPIC_PCT})<!-- ELSE --> - <!-- ENDIF --></dd> <!-- ENDIF --> </dl> </div> diff --git a/phpBB/styles/subsilver2/template/editor.js b/phpBB/styles/subsilver2/template/editor.js index cd22812bab..7cc5de9034 100644 --- a/phpBB/styles/subsilver2/template/editor.js +++ b/phpBB/styles/subsilver2/template/editor.js @@ -151,8 +151,10 @@ function insert_text(text, spaces, popup) { text = ' ' + text + ' '; } - - if (!isNaN(textarea.selectionStart)) + + // Since IE9, IE also has textarea.selectionStart, but it still needs to be treated the old way. + // Therefore we simply add a !is_ie here until IE fixes the text-selection completely. + if (!isNaN(textarea.selectionStart) && !is_ie) { var sel_start = textarea.selectionStart; var sel_end = textarea.selectionEnd; @@ -218,11 +220,12 @@ function addquote(post_id, username, l_wrote) } // Get text selection - not only the post content :( - if (window.getSelection) + // IE9 must use the document.selection method but has the *.getSelection so we just force no IE + if (window.getSelection && !is_ie) { theSelection = window.getSelection().toString(); } - else if (document.getSelection) + else if (document.getSelection && !is_ie) { theSelection = document.getSelection(); } diff --git a/phpBB/styles/subsilver2/template/memberlist_view.html b/phpBB/styles/subsilver2/template/memberlist_view.html index 0afa750c79..434d795895 100644 --- a/phpBB/styles/subsilver2/template/memberlist_view.html +++ b/phpBB/styles/subsilver2/template/memberlist_view.html @@ -89,11 +89,11 @@ <!-- IF S_SHOW_ACTIVITY --> <tr> <td class="gen" align="{S_CONTENT_FLOW_END}" valign="top" nowrap="nowrap">{L_ACTIVE_IN_FORUM}: </td> - <td><!-- IF ACTIVE_FORUM --><b><a class="gen" href="{U_ACTIVE_FORUM}">{ACTIVE_FORUM}</a></b><br /><span class="genmed">[ {ACTIVE_FORUM_POSTS} / {ACTIVE_FORUM_PCT} ]</span><!-- ELSE --><span class="gen">-</span><!-- ENDIF --></td> + <td><!-- IF ACTIVE_FORUM != '' --><b><a class="gen" href="{U_ACTIVE_FORUM}">{ACTIVE_FORUM}</a></b><br /><span class="genmed">[ {ACTIVE_FORUM_POSTS} / {ACTIVE_FORUM_PCT} ]</span><!-- ELSE --><span class="gen">-</span><!-- ENDIF --></td> </tr> <tr> <td class="gen" align="{S_CONTENT_FLOW_END}" valign="top" nowrap="nowrap">{L_ACTIVE_IN_TOPIC}: </td> - <td><!-- IF ACTIVE_TOPIC --><b><a class="gen" href="{U_ACTIVE_TOPIC}">{ACTIVE_TOPIC}</a></b><br /><span class="genmed">[ {ACTIVE_TOPIC_POSTS} / {ACTIVE_TOPIC_PCT} ]</span><!-- ELSE --><span class="gen">-</span><!-- ENDIF --></td> + <td><!-- IF ACTIVE_TOPIC != '' --><b><a class="gen" href="{U_ACTIVE_TOPIC}">{ACTIVE_TOPIC}</a></b><br /><span class="genmed">[ {ACTIVE_TOPIC_POSTS} / {ACTIVE_TOPIC_PCT} ]</span><!-- ELSE --><span class="gen">-</span><!-- ENDIF --></td> </tr> <!-- ENDIF --> </table> diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index ddea500f83..753cc08fc5 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -271,6 +271,66 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case 'foo' => array('UINT', 42))) ); + $this->assertTrue($this->tools->sql_table_exists('prefix_test_table')); + $this->tools->sql_table_drop('prefix_test_table'); + + $this->assertFalse($this->tools->sql_table_exists('prefix_test_table')); + } + + public function test_peform_schema_changes_drop_tables() + { + $db_tools = $this->getMock('phpbb_db_tools', array( + 'sql_table_exists', + 'sql_table_drop', + ), array(&$this->db)); + + // pretend all tables exist + $db_tools->expects($this->any())->method('sql_table_exists') + ->will($this->returnValue(true)); + + // drop tables + $db_tools->expects($this->exactly(2))->method('sql_table_drop'); + $db_tools->expects($this->at(1))->method('sql_table_drop') + ->with($this->equalTo('dropped_table_1')); + $db_tools->expects($this->at(3))->method('sql_table_drop') + ->with($this->equalTo('dropped_table_2')); + + $db_tools->perform_schema_changes(array( + 'drop_tables' => array( + 'dropped_table_1', + 'dropped_table_2', + ), + )); + } + + public function test_peform_schema_changes_drop_columns() + { + $db_tools = $this->getMock('phpbb_db_tools', array( + 'sql_column_exists', + 'sql_column_remove', + ), array(&$this->db)); + + // pretend all columns exist + $db_tools->expects($this->any())->method('sql_column_exists') + ->will($this->returnValue(true)); + $db_tools->expects($this->any())->method('sql_column_exists') + ->will($this->returnValue(true)); + + // drop columns + $db_tools->expects($this->exactly(2))->method('sql_column_remove'); + $db_tools->expects($this->at(1))->method('sql_column_remove') + ->with($this->equalTo('existing_table'), $this->equalTo('dropped_column_1')); + $db_tools->expects($this->at(3))->method('sql_column_remove') + ->with($this->equalTo('existing_table'), $this->equalTo('dropped_column_2')); + + $db_tools->perform_schema_changes(array( + 'drop_columns' => array( + 'existing_table' => array( + 'dropped_column_1', + 'dropped_column_2', + ), + ), + )); } } diff --git a/tests/utf/data/.gitkeep b/tests/tmp/.gitkeep index e69de29bb2..e69de29bb2 100644 --- a/tests/utf/data/.gitkeep +++ b/tests/tmp/.gitkeep diff --git a/tests/utf/normalizer_test.php b/tests/utf/normalizer_test.php index f78dba8004..a0ba470416 100644 --- a/tests/utf/normalizer_test.php +++ b/tests/utf/normalizer_test.php @@ -14,10 +14,13 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_normalizer.php'; */ class phpbb_utf_normalizer_test extends phpbb_test_case { + static private $data_dir; + static public function setUpBeforeClass() { - self::download('http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt', dirname(__FILE__).'/data'); - self::download('http://www.unicode.org/Public/UNIDATA/UnicodeData.txt', dirname(__FILE__).'/data'); + self::$data_dir = dirname(__file__) . '/../tmp'; + self::download('http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt', self::$data_dir); + self::download('http://www.unicode.org/Public/UNIDATA/UnicodeData.txt', self::$data_dir); } public function test_normalizer() @@ -62,7 +65,7 @@ class phpbb_utf_normalizer_test extends phpbb_test_case $tested_chars = array(); - $fp = fopen(dirname(__FILE__).'/data/NormalizationTest.txt', 'rb'); + $fp = fopen(self::$data_dir . '/NormalizationTest.txt', 'rb'); while (!feof($fp)) { $line = fgets($fp); @@ -117,7 +120,7 @@ class phpbb_utf_normalizer_test extends phpbb_test_case */ public function test_invariants(array $tested_chars) { - $fp = fopen(dirname(__FILE__).'/data/UnicodeData.txt', 'rb'); + $fp = fopen(self::$data_dir . '/UnicodeData.txt', 'rb'); while (!feof($fp)) { |