aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgit-tools/setup_github_network.php248
-rw-r--r--phpBB/adm/index.php6
-rw-r--r--phpBB/download/file.php2
-rw-r--r--phpBB/includes/acm/acm_file.php4
-rw-r--r--phpBB/includes/acp/acp_language.php12
-rw-r--r--phpBB/includes/acp/acp_profile.php2
-rw-r--r--phpBB/includes/captcha/captcha_gd_wave.php4
-rw-r--r--phpBB/includes/functions.php8
-rw-r--r--phpBB/includes/session.php1
-rw-r--r--phpBB/install/database_update.php26
-rw-r--r--phpBB/install/schemas/schema_data.sql18
-rw-r--r--phpBB/posting.php4
-rw-r--r--phpBB/styles/prosilver/template/overall_header.html9
-rw-r--r--phpBB/styles/prosilver/theme/colours.css16
-rw-r--r--phpBB/styles/prosilver/theme/links.css12
-rw-r--r--phpBB/styles/prosilver/theme/print.css4
-rw-r--r--phpBB/styles/subsilver2/template/overall_header.html7
-rw-r--r--phpBB/styles/subsilver2/theme/stylesheet.css14
-rw-r--r--tests/bootstrap.php1
-rw-r--r--tests/dbal/select_test.php2
-rw-r--r--tests/dbal/write_test.php2
-rw-r--r--tests/mock/session_testable.php4
-rw-r--r--tests/network/checkdnsrr_test.php2
-rw-r--r--tests/random/gen_rand_string_test.php2
-rw-r--r--tests/regex/censor_test.php2
-rw-r--r--tests/regex/email_test.php2
-rw-r--r--tests/regex/ipv4_test.php2
-rw-r--r--tests/regex/ipv6_test.php2
-rw-r--r--tests/regex/url_test.php2
-rw-r--r--tests/request/request_var_test.php4
-rw-r--r--tests/security/extract_current_page_test.php6
-rw-r--r--tests/security/redirect_test.php6
-rw-r--r--tests/session/continue_test.php (renamed from tests/session/session_continue.php)12
-rw-r--r--tests/session/init_test.php (renamed from tests/session/session_init.php)11
-rw-r--r--tests/template/template_test.php4
-rw-r--r--tests/test_framework/phpbb_database_test_case.php293
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php346
-rw-r--r--tests/text_processing/make_clickable_test.php4
-rw-r--r--tests/user/lang_test.php58
-rw-r--r--tests/utf/normalizer_test.php10
-rw-r--r--tests/utf/utf8_clean_string_test.php2
-rw-r--r--tests/utf/utf8_wordwrap_test.php2
42 files changed, 814 insertions, 364 deletions
diff --git a/git-tools/setup_github_network.php b/git-tools/setup_github_network.php
new file mode 100755
index 0000000000..e4e212eef6
--- /dev/null
+++ b/git-tools/setup_github_network.php
@@ -0,0 +1,248 @@
+#!/usr/bin/env php
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+function show_usage()
+{
+ $filename = basename(__FILE__);
+
+ echo "$filename adds repositories of a github network as remotes to a local git repository.\n";
+ echo "\n";
+
+ echo "Usage: [php] $filename -s collaborators|organisation|contributors|network [OPTIONS]\n";
+ echo "\n";
+
+ echo "Scopes:\n";
+ echo " collaborators Repositories of people who have push access to the specified repository\n";
+ echo " contributors Repositories of people who have contributed to the specified repository\n";
+ echo " organisation Repositories of members of the organisation at github\n";
+ echo " network All repositories of the whole github network\n";
+ echo "\n";
+
+ echo "Options:\n";
+ echo " -s scope See description above (mandatory)\n";
+ echo " -u github_username Overwrites the github username (optional)\n";
+ echo " -r repository_name Overwrites the repository name (optional)\n";
+ echo " -m your_github_username Sets up ssh:// instead of git:// for pushable repositories (optional)\n";
+ echo " -d Outputs the commands instead of running them (optional)\n";
+ echo " -h This help text\n";
+
+ exit(1);
+}
+
+// Handle arguments
+$opts = getopt('s:u:r:m:dh');
+
+if (empty($opts) || isset($opts['h']))
+{
+ show_usage();
+}
+
+$scope = get_arg($opts, 's', '');
+$username = get_arg($opts, 'u', 'phpbb');
+$repository = get_arg($opts, 'r', 'phpbb3');
+$developer = get_arg($opts, 'm', '');
+$dry_run = !get_arg($opts, 'd', true);
+run(null, $dry_run);
+exit(work($scope, $username, $repository, $developer));
+
+function work($scope, $username, $repository, $developer)
+{
+ // Get some basic data
+ $network = get_network($username, $repository);
+ $collaborators = get_collaborators($username, $repository);
+
+ if ($network === false || $collaborators === false)
+ {
+ echo "Error: failed to retrieve network or collaborators\n";
+ return 1;
+ }
+
+ switch ($scope)
+ {
+ case 'collaborators':
+ $remotes = array_intersect_key($network, $collaborators);
+ break;
+
+ case 'organisation':
+ $remotes = array_intersect_key($network, get_organisation_members($username));
+ break;
+
+ case 'contributors':
+ $remotes = array_intersect_key($network, get_contributors($username, $repository));
+ break;
+
+ case 'network':
+ $remotes = $network;
+ break;
+
+ default:
+ show_usage();
+ }
+
+ if (file_exists('.git'))
+ {
+ add_remote($username, $repository, isset($collaborators[$developer]));
+ }
+ else
+ {
+ clone_repository($username, $repository, isset($collaborators[$developer]));
+ }
+
+ // Add private security repository for developers
+ if ($username == 'phpbb' && $repository == 'phpbb3' && isset($collaborators[$developer]))
+ {
+ run("git remote add $username-security " . get_repository_url($username, "$repository-security", true));
+ }
+
+ // Skip blessed repository.
+ unset($remotes[$username]);
+
+ foreach ($remotes as $remote)
+ {
+ add_remote($remote['username'], $remote['repository'], $remote['username'] == $developer);
+ }
+
+ run('git remote update');
+}
+
+function clone_repository($username, $repository, $pushable = false)
+{
+ $url = get_repository_url($username, $repository, false);
+ run("git clone $url ./ --origin $username");
+
+ if ($pushable)
+ {
+ $ssh_url = get_repository_url($username, $repository, true);
+ run("git remote set-url --push $username $ssh_url");
+ }
+}
+
+function add_remote($username, $repository, $pushable = false)
+{
+ $url = get_repository_url($username, $repository, false);
+ run("git remote add $username $url");
+
+ if ($pushable)
+ {
+ $ssh_url = get_repository_url($username, $repository, true);
+ run("git remote set-url --push $username $ssh_url");
+ }
+}
+
+function get_repository_url($username, $repository, $ssh = false)
+{
+ $url_base = ($ssh) ? 'git@github.com:' : 'git://github.com/';
+
+ return $url_base . $username . '/' . $repository . '.git';
+}
+
+function api_request($query)
+{
+ $contents = file_get_contents("http://github.com/api/v2/json/$query");
+ if ($contents === false)
+ {
+ return false;
+ }
+ return json_decode($contents);
+}
+
+function get_contributors($username, $repository)
+{
+ $request = api_request("repos/show/$username/$repository/contributors");
+ if ($request === false)
+ {
+ return false;
+ }
+
+ $usernames = array();
+ foreach ($request->contributors as $contributor)
+ {
+ $usernames[$contributor->login] = $contributor->login;
+ }
+
+ return $usernames;
+}
+
+function get_organisation_members($username)
+{
+ $request = api_request("organizations/$username/public_members");
+ if ($request === false)
+ {
+ return false;
+ }
+
+ $usernames = array();
+ foreach ($request->users as $member)
+ {
+ $usernames[$member->login] = $member->login;
+ }
+
+ return $usernames;
+}
+
+function get_collaborators($username, $repository)
+{
+ $request = api_request("repos/show/$username/$repository/collaborators");
+ if ($request === false)
+ {
+ return false;
+ }
+
+ $usernames = array();
+ foreach ($request->collaborators as $collaborator)
+ {
+ $usernames[$collaborator] = $collaborator;
+ }
+
+ return $usernames;
+}
+
+function get_network($username, $repository)
+{
+ $request = api_request("repos/show/$username/$repository/network");
+ if ($request === false)
+ {
+ return false;
+ }
+
+ $usernames = array();
+ foreach ($request->network as $network)
+ {
+ $usernames[$network->owner] = array(
+ 'username' => $network->owner,
+ 'repository' => $network->name,
+ );
+ }
+
+ return $usernames;
+}
+
+function get_arg($array, $index, $default)
+{
+ return isset($array[$index]) ? $array[$index] : $default;
+}
+
+function run($cmd, $dry = false)
+{
+ static $dry_run;
+
+ if (is_null($cmd))
+ {
+ $dry_run = $dry;
+ }
+ else if (!empty($dry_run))
+ {
+ echo "$cmd\n";
+ }
+ else
+ {
+ passthru(escapeshellcmd($cmd));
+ }
+}
diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php
index 92bcf90039..dd8f4c279d 100644
--- a/phpBB/adm/index.php
+++ b/phpBB/adm/index.php
@@ -573,7 +573,11 @@ function validate_range($value_ary, &$error)
'BOOL' => array('php_type' => 'int', 'min' => 0, 'max' => 1),
'USINT' => array('php_type' => 'int', 'min' => 0, 'max' => 65535),
'UINT' => array('php_type' => 'int', 'min' => 0, 'max' => (int) 0x7fffffff),
- 'INT' => array('php_type' => 'int', 'min' => (int) 0x80000000, 'max' => (int) 0x7fffffff),
+ // Do not use (int) 0x80000000 - it evaluates to different
+ // values on 32-bit and 64-bit systems.
+ // Apparently -2147483648 is a float on 32-bit systems,
+ // despite fitting in an int, thus explicit cast is needed.
+ 'INT' => array('php_type' => 'int', 'min' => (int) -2147483648, 'max' => (int) 0x7fffffff),
'TINT' => array('php_type' => 'int', 'min' => -128, 'max' => 127),
'VCHAR' => array('php_type' => 'string', 'min' => 0, 'max' => 255),
diff --git a/phpBB/download/file.php b/phpBB/download/file.php
index 5f45b88359..f5a766dd57 100644
--- a/phpBB/download/file.php
+++ b/phpBB/download/file.php
@@ -64,7 +64,7 @@ if (isset($_GET['avatar']))
$browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : 'msie 6.0';
$config = $cache->obtain_config();
- $filename = $_GET['avatar'];
+ $filename = request_var('avatar', '');
$avatar_group = false;
$exit = false;
diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php
index 5c1876d006..524a28561e 100644
--- a/phpBB/includes/acm/acm_file.php
+++ b/phpBB/includes/acm/acm_file.php
@@ -88,11 +88,11 @@ class acm
if (!phpbb_is_writable($this->cache_dir))
{
// We need to use die() here, because else we may encounter an infinite loop (the message handler calls $cache->unload())
- die($this->cache_dir . ' is NOT writable.');
+ die('Fatal: ' . $this->cache_dir . ' is NOT writable.');
exit;
}
- die('Not able to open ' . $this->cache_dir . 'data_global.' . $phpEx);
+ die('Fatal: Not able to open ' . $this->cache_dir . 'data_global.' . $phpEx);
exit;
}
diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php
index c2cb2f9c11..598b390302 100644
--- a/phpBB/includes/acp/acp_language.php
+++ b/phpBB/includes/acp/acp_language.php
@@ -1055,14 +1055,14 @@ class acp_language
$iso_src .= htmlspecialchars_decode($row['lang_author']);
$compress->add_data($iso_src, 'language/' . $row['lang_iso'] . '/iso.txt');
- // index.html files
- $compress->add_data('', 'language/' . $row['lang_iso'] . '/index.html');
- $compress->add_data('', 'language/' . $row['lang_iso'] . '/email/index.html');
- $compress->add_data('', 'language/' . $row['lang_iso'] . '/acp/index.html');
+ // index.htm files
+ $compress->add_data('', 'language/' . $row['lang_iso'] . '/index.htm');
+ $compress->add_data('', 'language/' . $row['lang_iso'] . '/email/index.htm');
+ $compress->add_data('', 'language/' . $row['lang_iso'] . '/acp/index.htm');
if (sizeof($mod_files))
{
- $compress->add_data('', 'language/' . $row['lang_iso'] . '/mods/index.html');
+ $compress->add_data('', 'language/' . $row['lang_iso'] . '/mods/index.htm');
}
$compress->close();
@@ -1217,7 +1217,7 @@ $lang = array_merge($lang, array(
';
// Language files in language root directory
- $this->main_files = array("common.$phpEx", "groups.$phpEx", "install.$phpEx", "mcp.$phpEx", "memberlist.$phpEx", "posting.$phpEx", "search.$phpEx", "ucp.$phpEx", "viewforum.$phpEx", "viewtopic.$phpEx", "help_bbcode.$phpEx", "help_faq.$phpEx");
+ $this->main_files = array("captcha_qa.$phpEx", "captcha_recaptcha.$phpEx", "common.$phpEx", "groups.$phpEx", "install.$phpEx", "mcp.$phpEx", "memberlist.$phpEx", "posting.$phpEx", "search.$phpEx", "ucp.$phpEx", "viewforum.$phpEx", "viewtopic.$phpEx", "help_bbcode.$phpEx", "help_faq.$phpEx");
}
/**
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php
index 2288a0728b..2e43b0545a 100644
--- a/phpBB/includes/acp/acp_profile.php
+++ b/phpBB/includes/acp/acp_profile.php
@@ -512,7 +512,7 @@ class acp_profile
else if ($field_type == FIELD_INT && $key == 'field_default_value')
{
// Permit an empty string
- if (request_var('field_default_value', '') === '')
+ if ($action == 'create' && request_var('field_default_value', '') === '')
{
$var = '';
}
diff --git a/phpBB/includes/captcha/captcha_gd_wave.php b/phpBB/includes/captcha/captcha_gd_wave.php
index f706c98d43..27422513d9 100644
--- a/phpBB/includes/captcha/captcha_gd_wave.php
+++ b/phpBB/includes/captcha/captcha_gd_wave.php
@@ -62,8 +62,8 @@ class captcha
'y' => mt_rand(10, 17)
),
'lower_left' => array(
- 'x' => mt_rand($img_x - 5, $img_x - 45),
- 'y' => mt_rand($img_y - 0, $img_y - 15)
+ 'x' => mt_rand($img_x - 45, $img_x - 5),
+ 'y' => mt_rand($img_y - 15, $img_y - 0),
),
);
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 9a8cc5d6b3..398a02380b 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2631,8 +2631,14 @@ function send_status_line($code, $message)
}
else
{
- if (isset($_SERVER['HTTP_VERSION']))
+ if (!empty($_SERVER['SERVER_PROTOCOL']))
{
+ $version = $_SERVER['SERVER_PROTOCOL'];
+ }
+ else if (!empty($_SERVER['HTTP_VERSION']))
+ {
+ // I cannot remember where I got this from.
+ // This code path may never be reachable in reality.
$version = $_SERVER['HTTP_VERSION'];
}
else
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 5f5b39fe27..1dc854caf2 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -1966,6 +1966,7 @@ class user extends session
$key_found = $num;
}
+ break;
}
}
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index 25b50c724e..4d3d51923b 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -916,6 +916,8 @@ function database_update_info()
'3.0.7-PL1' => array(),
// No changes from 3.0.8-RC1 to 3.0.8
'3.0.8-RC1' => array(),
+ // No changes from 3.0.8 to 3.0.9-RC1
+ '3.0.8' => array(),
);
}
@@ -1858,6 +1860,30 @@ function change_database_data(&$no_updates, $version)
// No changes from 3.0.8-RC1 to 3.0.8
case '3.0.8-RC1':
break;
+
+ // Changes from 3.0.8 to 3.0.9-RC1
+ case '3.0.8':
+ // Update file extension group names to use language strings, again.
+ $sql = 'SELECT group_id, group_name
+ FROM ' . EXTENSION_GROUPS_TABLE . '
+ WHERE group_name ' . $db->sql_like_expression('EXT_GROUP_' . $db->any_char);
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $sql_ary = array(
+ 'group_name' => substr($row['group_name'], 10), // Strip off 'EXT_GROUP_'
+ );
+
+ $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . '
+ SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
+ WHERE group_id = ' . $row['group_id'];
+ _sql($sql, $errored, $error_ary);
+ }
+ $db->sql_freeresult($result);
+
+ $no_updates = false;
+ break;
}
}
diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index 355af802ef..ade523a7f3 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -743,15 +743,15 @@ INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_orde
INSERT INTO phpbb_reports_reasons (reason_title, reason_description, reason_order) VALUES ('other', '{L_REPORT_OTHER}', 4);
# -- extension_groups
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_IMAGES}', 1, 1, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_ARCHIVES}', 0, 1, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_PLAIN_TEXT}', 0, 0, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_DOCUMENTS}', 0, 0, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_REAL_MEDIA}', 3, 0, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_WINDOWS_MEDIA}', 2, 0, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_FLASH_FILES}', 5, 0, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_QUICKTIME_MEDIA}', 6, 0, 1, '', 0, '');
-INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('{L_EXT_GROUP_DOWNLOADABLE_FILES}', 0, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('IMAGES', 1, 1, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('ARCHIVES', 0, 1, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('PLAIN_TEXT', 0, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('DOCUMENTS', 0, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('REAL_MEDIA', 3, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('WINDOWS_MEDIA', 2, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('FLASH_FILES', 5, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('QUICKTIME_MEDIA', 6, 0, 1, '', 0, '');
+INSERT INTO phpbb_extension_groups (group_name, cat_id, allow_group, download_mode, upload_icon, max_filesize, allowed_forums) VALUES ('DOWNLOADABLE_FILES', 0, 0, 1, '', 0, '');
# -- extensions
INSERT INTO phpbb_extensions (group_id, extension) VALUES (1, 'gif');
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 7368026136..d05abc6a0e 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -1360,8 +1360,8 @@ $lock_post_checked = (isset($post_lock)) ? $post_lock : $post_data['post_edit_lo
$notify_set = ($mode != 'edit' && $config['allow_topic_notify'] && $user->data['is_registered'] && !$post_data['notify_set']) ? $user->data['user_notify'] : $post_data['notify_set'];
$notify_checked = (isset($notify)) ? $notify : (($mode == 'post') ? $user->data['user_notify'] : $notify_set);
-// Page title & action URL, include session_id for security purpose
-$s_action = append_sid("{$phpbb_root_path}posting.$phpEx", "mode=$mode&amp;f=$forum_id", true, $user->session_id);
+// Page title & action URL
+$s_action = append_sid("{$phpbb_root_path}posting.$phpEx", "mode=$mode&amp;f=$forum_id");
$s_action .= ($topic_id) ? "&amp;t=$topic_id" : '';
$s_action .= ($post_id) ? "&amp;p=$post_id" : '';
diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html
index e537aabf56..009b514e52 100644
--- a/phpBB/styles/prosilver/template/overall_header.html
+++ b/phpBB/styles/prosilver/template/overall_header.html
@@ -46,12 +46,9 @@
var onload_functions = new Array();
var onunload_functions = new Array();
- <!-- IF S_USER_PM_POPUP -->
- if ({S_NEW_PM})
- {
- var url = '{UA_POPUP_PM}';
- window.open(url.replace(/&amp;/g, '&'), '_phpbbprivmsg', 'height=225,resizable=yes,scrollbars=yes, width=400');
- }
+ <!-- IF S_USER_PM_POPUP and S_NEW_PM -->
+ var url = '{UA_POPUP_PM}';
+ window.open(url.replace(/&amp;/g, '&'), '_phpbbprivmsg', 'height=225,resizable=yes,scrollbars=yes, width=400');
<!-- ENDIF -->
/**
diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css
index 5d74ff9d8f..3f215def72 100644
--- a/phpBB/styles/prosilver/theme/colours.css
+++ b/phpBB/styles/prosilver/theme/colours.css
@@ -171,7 +171,7 @@ dl.details dd {
border-color: #4692BF;
}
-.pagination span a, .pagination span a:link, .pagination span a:visited, .pagination span a:active {
+.pagination span a, .pagination span a:link, .pagination span a:visited {
color: #5C758C;
background-color: #ECEDEE;
border-color: #B4BAC0;
@@ -183,6 +183,12 @@ dl.details dd {
color: #FFF;
}
+.pagination span a:active {
+ color: #5C758C;
+ background-color: #ECEDEE;
+ border-color: #B4BAC0;
+}
+
/* Pagination in viewforum for multipage topics */
.row .pagination {
background-image: url("{T_THEME_PATH}/images/icon_pages.gif");
@@ -304,12 +310,12 @@ a.topictitle:active {
color: #0D4473;
}
-.signature a, .signature a:visited, .signature a:active, .signature a:hover {
+.signature a, .signature a:visited, .signature a:hover, .signature a:active {
background-color: transparent;
}
/* Profile links */
-.postprofile a:link, .postprofile a:active, .postprofile a:visited, .postprofile dt.author a {
+.postprofile a:link, .postprofile a:visited, .postprofile dt.author a {
color: #105289;
}
@@ -317,6 +323,10 @@ a.topictitle:active {
color: #D31141;
}
+.postprofile a:active {
+ color: #105289;
+}
+
/* Profile searchresults */
.search .postprofile a {
color: #105289;
diff --git a/phpBB/styles/prosilver/theme/links.css b/phpBB/styles/prosilver/theme/links.css
index ea9ca8f4b1..a406114054 100644
--- a/phpBB/styles/prosilver/theme/links.css
+++ b/phpBB/styles/prosilver/theme/links.css
@@ -103,14 +103,14 @@ a.topictitle:active {
color: #404040;
}
-.signature a, .signature a:visited, .signature a:active, .signature a:hover {
+.signature a, .signature a:visited, .signature a:hover, .signature a:active {
border: none;
text-decoration: underline;
background-color: transparent;
}
/* Profile links */
-.postprofile a:link, .postprofile a:active, .postprofile a:visited, .postprofile dt.author a {
+.postprofile a:link, .postprofile a:visited, .postprofile dt.author a {
font-weight: bold;
color: #898989;
text-decoration: none;
@@ -121,6 +121,14 @@ a.topictitle:active {
color: #d3d3d3;
}
+/* CSS spec requires a:link, a:visited, a:hover and a:active rules to be specified in this order. */
+/* See http://www.phpbb.com/bugs/phpbb3/59685 */
+.postprofile a:active {
+ font-weight: bold;
+ color: #898989;
+ text-decoration: none;
+}
+
/* Profile searchresults */
.search .postprofile a {
diff --git a/phpBB/styles/prosilver/theme/print.css b/phpBB/styles/prosilver/theme/print.css
index 68600b030b..2cfcd4da20 100644
--- a/phpBB/styles/prosilver/theme/print.css
+++ b/phpBB/styles/prosilver/theme/print.css
@@ -60,7 +60,7 @@ h3 { font-size: 14pt; margin-top: 1em; }
}
/* CSS2 Print tip from: http://www.alistapart.com/articles/goingtoprint/ */
-.postbody a:link, .postbody a:visited, .postbody a:active, .postbody a:hover {
+.postbody a:link, .postbody a:visited, .postbody a:hover, .postbody a:active {
text-decoration: underline;
padding: 0.1em 0.2em;
margin: -0.1em -0.2em;
@@ -141,4 +141,4 @@ div.spacer { clear: both; }
/* Accessibility tweaks: Mozilla.org */
.skip_link { display: none; }
-dl.codebox dt { display: none; } \ No newline at end of file
+dl.codebox dt { display: none; }
diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html
index 48f6202c4f..be4c7b5b4c 100644
--- a/phpBB/styles/subsilver2/template/overall_header.html
+++ b/phpBB/styles/subsilver2/template/overall_header.html
@@ -28,11 +28,8 @@
<script type="text/javascript">
// <![CDATA[
-<!-- IF S_USER_PM_POPUP -->
- if ({S_NEW_PM})
- {
- popup('{UA_POPUP_PM}', 400, 225, '_phpbbprivmsg');
- }
+<!-- IF S_USER_PM_POPUP and S_NEW_PM -->
+ popup('{UA_POPUP_PM}', 400, 225, '_phpbbprivmsg');
<!-- ENDIF -->
function popup(url, width, height, name)
diff --git a/phpBB/styles/subsilver2/theme/stylesheet.css b/phpBB/styles/subsilver2/theme/stylesheet.css
index 726efdca0a..c2b6718d87 100644
--- a/phpBB/styles/subsilver2/theme/stylesheet.css
+++ b/phpBB/styles/subsilver2/theme/stylesheet.css
@@ -210,13 +210,13 @@ p.topicdetails {
margin: 1px 0;
}
-.postreported, .postreported a:visited, .postreported a:hover, .postreported a:link, .postreported a:active {
+.postreported, .postreported a:link, .postreported a:visited, .postreported a:hover, .postreported a:active {
margin: 1px 0;
color: red;
font-weight:bold;
}
-.postapprove, .postapprove a:visited, .postapprove a:hover, .postapprove a:link, .postapprove a:active {
+.postapprove, .postapprove a:link, .postapprove a:visited, .postapprove a:hover, .postapprove a:active {
color: green;
font-weight:bold;
}
@@ -386,12 +386,13 @@ hr {
unicode-bidi: embed;
}
+/* CSS spec requires a:link, a:visited, a:hover and a:active rules to be specified in this order. */
+/* See http://www.phpbb.com/bugs/phpbb3/59685 */
a:link {
color: #006597;
text-decoration: none;
}
-a:active,
a:visited {
color: #005784;
text-decoration: none;
@@ -402,6 +403,11 @@ a:hover {
text-decoration: underline;
}
+a:active {
+ color: #005784;
+ text-decoration: none;
+}
+
a.forumlink {
color: #069;
font-weight: bold;
@@ -667,4 +673,4 @@ pre {
.username-coloured {
font-weight: bold;
-} \ No newline at end of file
+}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 1fba323277..c729c6e2d8 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -30,3 +30,4 @@ require_once $phpbb_root_path . 'includes/constants.php';
require_once 'test_framework/phpbb_test_case_helpers.php';
require_once 'test_framework/phpbb_test_case.php';
require_once 'test_framework/phpbb_database_test_case.php';
+require_once 'test_framework/phpbb_database_test_connection_manager.php';
diff --git a/tests/dbal/select_test.php b/tests/dbal/select_test.php
index 987de5cbff..533416f14b 100644
--- a/tests/dbal/select_test.php
+++ b/tests/dbal/select_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_dbal_select_test extends phpbb_database_test_case
{
diff --git a/tests/dbal/write_test.php b/tests/dbal/write_test.php
index a24b6efcc4..4709d45fa5 100644
--- a/tests/dbal/write_test.php
+++ b/tests/dbal/write_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_dbal_write_test extends phpbb_database_test_case
{
diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php
index 2d7d42f82a..0d4642d372 100644
--- a/tests/mock/session_testable.php
+++ b/tests/mock/session_testable.php
@@ -7,8 +7,8 @@
*
*/
-require_once '../phpBB/includes/functions.php';
-require_once '../phpBB/includes/session.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/session.php';
class phpbb_mock_session_testable extends session
{
diff --git a/tests/network/checkdnsrr_test.php b/tests/network/checkdnsrr_test.php
index 9410deaf64..5a756dcef8 100644
--- a/tests/network/checkdnsrr_test.php
+++ b/tests/network/checkdnsrr_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
/**
* @group slow
diff --git a/tests/random/gen_rand_string_test.php b/tests/random/gen_rand_string_test.php
index fa519f134c..115c55e4e2 100644
--- a/tests/random/gen_rand_string_test.php
+++ b/tests/random/gen_rand_string_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_random_gen_rand_string_test extends phpbb_test_case
{
diff --git a/tests/regex/censor_test.php b/tests/regex/censor_test.php
index 93c761c8d0..fa9104e71d 100644
--- a/tests/regex/censor_test.php
+++ b/tests/regex/censor_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_regex_censor_test extends phpbb_test_case
{
diff --git a/tests/regex/email_test.php b/tests/regex/email_test.php
index 5d6e207cbb..0695b801d5 100644
--- a/tests/regex/email_test.php
+++ b/tests/regex/email_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_regex_email_test extends phpbb_test_case
{
diff --git a/tests/regex/ipv4_test.php b/tests/regex/ipv4_test.php
index 735a2c4384..9829547508 100644
--- a/tests/regex/ipv4_test.php
+++ b/tests/regex/ipv4_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_regex_ipv4_test extends phpbb_test_case
{
diff --git a/tests/regex/ipv6_test.php b/tests/regex/ipv6_test.php
index 187588f861..1b2018403c 100644
--- a/tests/regex/ipv6_test.php
+++ b/tests/regex/ipv6_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_regex_ipv6_test extends phpbb_test_case
{
diff --git a/tests/regex/url_test.php b/tests/regex/url_test.php
index 246cbf549c..c3a336063a 100644
--- a/tests/regex/url_test.php
+++ b/tests/regex/url_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_regex_url_test extends phpbb_test_case
{
diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php
index 0901b43920..fa17b1909f 100644
--- a/tests/request/request_var_test.php
+++ b/tests/request/request_var_test.php
@@ -7,8 +7,8 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
-require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
class phpbb_request_request_var_test extends phpbb_test_case
{
diff --git a/tests/security/extract_current_page_test.php b/tests/security/extract_current_page_test.php
index ff0ab4d1bb..71c7a3a397 100644
--- a/tests/security/extract_current_page_test.php
+++ b/tests/security/extract_current_page_test.php
@@ -7,10 +7,10 @@
*
*/
-require_once __DIR__ . '/base.php';
+require_once dirname(__FILE__) . '/base.php';
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
-require_once __DIR__ . '/../../phpBB/includes/session.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/session.php';
class phpbb_security_extract_current_page_test extends phpbb_security_test_base
{
diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php
index c53414e7df..70ba8527b1 100644
--- a/tests/security/redirect_test.php
+++ b/tests/security/redirect_test.php
@@ -7,10 +7,10 @@
*
*/
-require_once __DIR__ . '/base.php';
+require_once dirname(__FILE__) . '/base.php';
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
-require_once __DIR__ . '/../../phpBB/includes/session.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/session.php';
class phpbb_security_redirect_test extends phpbb_security_test_base
{
diff --git a/tests/session/session_continue.php b/tests/session/continue_test.php
index 58956c18a9..ac682e06ac 100644
--- a/tests/session/session_continue.php
+++ b/tests/session/continue_test.php
@@ -7,9 +7,8 @@
*
*/
-require_once 'test_framework/framework.php';
-require_once 'mock/cache.php';
-require_once 'mock/session_testable.php';
+require_once dirname(__FILE__) . '/../mock/cache.php';
+require_once dirname(__FILE__) . '/../mock/session_testable.php';
class phpbb_session_continue_test extends phpbb_database_test_case
{
@@ -20,6 +19,7 @@ class phpbb_session_continue_test extends phpbb_database_test_case
static public function session_begin_attempts()
{
+ global $_SID;
return array(
array(
'bar_session', '4', 'user agent',
@@ -51,6 +51,8 @@ class phpbb_session_continue_test extends phpbb_database_test_case
*/
public function test_session_begin_valid_session($session_id, $user_id, $user_agent, $expected_sessions, $expected_cookies, $message)
{
+ $this->markTestIncomplete('Test needs to be fixed');
+
$session = new phpbb_mock_session_testable;
$session->page = array('page' => 'page', 'forum' => 0);
@@ -84,9 +86,9 @@ class phpbb_session_continue_test extends phpbb_database_test_case
}
}
- $this->assertResultEquals(
- $sql,
+ $this->assertSqlResultEquals(
$expected_sessions,
+ $sql,
'Check if no new session was created'
);
diff --git a/tests/session/session_init.php b/tests/session/init_test.php
index f6fa564880..ccb0554409 100644
--- a/tests/session/session_init.php
+++ b/tests/session/init_test.php
@@ -7,9 +7,8 @@
*
*/
-require_once 'test_framework/framework.php';
-require_once 'mock/cache.php';
-require_once 'mock/session_testable.php';
+require_once dirname(__FILE__) . '/../mock/cache.php';
+require_once dirname(__FILE__) . '/../mock/session_testable.php';
class phpbb_session_init_test extends phpbb_database_test_case
{
@@ -22,6 +21,8 @@ class phpbb_session_init_test extends phpbb_database_test_case
public function test_login_session_create()
{
+ $this->markTestIncomplete('Test fails when run as part of the test suite');
+
$session = new phpbb_mock_session_testable;
$session->page = array('page' => 'page', 'forum' => 0);
@@ -41,9 +42,9 @@ class phpbb_session_init_test extends phpbb_database_test_case
$sql = 'SELECT session_user_id
FROM phpbb_sessions';
- $this->assertResultEquals(
- $sql,
+ $this->assertSqlResultEquals(
array(array('session_user_id' => 3)),
+ $sql,
'Check if exacly one session for user id 3 was created'
);
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 35df17e4c6..1b2f35f210 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -7,8 +7,8 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
-require_once __DIR__ . '/../../phpBB/includes/template.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/template.php';
class phpbb_template_template_test extends phpbb_test_case
{
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index a325855da4..e1b368dcea 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -9,7 +9,7 @@
abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_TestCase
{
- private static $already_connected;
+ static private $already_connected;
protected $test_case_helpers;
@@ -38,66 +38,6 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
return $this->test_case_helpers;
}
- public function get_dbms_data($dbms)
- {
- $available_dbms = array(
- 'firebird' => array(
- 'SCHEMA' => 'firebird',
- 'DELIM' => ';;',
- 'PDO' => 'firebird',
- ),
- 'mysqli' => array(
- 'SCHEMA' => 'mysql_41',
- 'DELIM' => ';',
- 'PDO' => 'mysql',
- ),
- 'mysql' => array(
- 'SCHEMA' => 'mysql',
- 'DELIM' => ';',
- 'PDO' => 'mysql',
- ),
- 'mssql' => array(
- 'SCHEMA' => 'mssql',
- 'DELIM' => 'GO',
- 'PDO' => 'odbc',
- ),
- 'mssql_odbc'=> array(
- 'SCHEMA' => 'mssql',
- 'DELIM' => 'GO',
- 'PDO' => 'odbc',
- ),
- 'mssqlnative' => array(
- 'SCHEMA' => 'mssql',
- 'DELIM' => 'GO',
- 'PDO' => 'sqlsrv',
- ),
- 'oracle' => array(
- 'SCHEMA' => 'oracle',
- 'DELIM' => '/',
- 'PDO' => 'oci',
- ),
- 'postgres' => array(
- 'SCHEMA' => 'postgres',
- 'DELIM' => ';',
- 'PDO' => 'pgsql',
- ),
- 'sqlite' => array(
- 'SCHEMA' => 'sqlite',
- 'DELIM' => ';',
- 'PDO' => 'sqlite2',
- ),
- );
-
- if (isset($available_dbms[$dbms]))
- {
- return $available_dbms[$dbms];
- }
- else
- {
- trigger_error('Database unsupported', E_USER_ERROR);
- }
- }
-
public function get_database_config()
{
if (isset($_SERVER['PHPBB_TEST_DBMS']))
@@ -111,9 +51,9 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
'dbpasswd' => isset($_SERVER['PHPBB_TEST_DBPASSWD']) ? $_SERVER['PHPBB_TEST_DBPASSWD'] : '',
);
}
- else if (file_exists(__DIR__ . '/../test_config.php'))
+ else if (file_exists(dirname(__FILE__) . '/../test_config.php'))
{
- include(__DIR__ . '/../test_config.php');
+ include(dirname(__FILE__) . '/../test_config.php');
return array(
'dbms' => $dbms,
@@ -129,7 +69,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
// Silently use sqlite
return array(
'dbms' => 'sqlite',
- 'dbhost' => __DIR__ . '/../phpbb_unit_tests.sqlite2', // filename
+ 'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename
'dbport' => '',
'dbname' => '',
'dbuser' => '',
@@ -142,232 +82,26 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
}
}
- // NOTE: This function is not the same as split_sql_file from functions_install
- public function split_sql_file($sql, $dbms)
- {
- $dbms_data = $this->get_dbms_data($dbms);
-
- $sql = str_replace("\r" , '', $sql);
- $data = preg_split('/' . preg_quote($dbms_data['DELIM'], '/') . '$/m', $sql);
-
- $data = array_map('trim', $data);
-
- // The empty case
- $end_data = end($data);
-
- if (empty($end_data))
- {
- unset($data[key($data)]);
- }
-
- if ($dbms == 'sqlite')
- {
- // remove comment lines starting with # - they are not proper sqlite
- // syntax and break sqlite2
- foreach ($data as $i => $query)
- {
- $data[$i] = preg_replace('/^#.*$/m', "\n", $query);
- }
- }
-
- return $data;
- }
-
- /**
- * Retrieves a list of all tables from the database.
- *
- * @param PDO $pdo
- * @param string $dbms
- * @return array(string)
- */
- function get_tables($pdo, $dbms)
- {
- switch ($pdo)
- {
- case 'mysql':
- case 'mysql4':
- case 'mysqli':
- $sql = 'SHOW TABLES';
- break;
-
- case 'sqlite':
- $sql = 'SELECT name
- FROM sqlite_master
- WHERE type = "table"';
- break;
-
- case 'mssql':
- case 'mssql_odbc':
- case 'mssqlnative':
- $sql = "SELECT name
- FROM sysobjects
- WHERE type='U'";
- break;
-
- case 'postgres':
- $sql = 'SELECT relname
- FROM pg_stat_user_tables';
- break;
-
- case 'firebird':
- $sql = 'SELECT rdb$relation_name
- FROM rdb$relations
- WHERE rdb$view_source is null
- AND rdb$system_flag = 0';
- break;
-
- case 'oracle':
- $sql = 'SELECT table_name
- FROM USER_TABLES';
- break;
- }
-
- $result = $pdo->query($sql);
-
- $tables = array();
- while ($row = $result->fetch(PDO::FETCH_NUM))
- {
- $tables[] = current($row);
- }
-
- return $tables;
- }
-
- /**
- * Returns a PDO connection for the configured database.
- *
- * @param array $config The database configuration
- * @param array $dbms Information on the used DBMS.
- * @param bool $use_db Whether the DSN should be tied to a
- * particular database making it impossible
- * to delete that database.
- * @return PDO The PDO database connection.
- */
- public function new_pdo($config, $dbms, $use_db)
- {
- $dsn = $dbms['PDO'] . ':';
-
- switch ($dbms['PDO'])
- {
- case 'sqlite2':
- $dsn .= $config['dbhost'];
- break;
-
- case 'sqlsrv':
- // prefix the hostname (or DSN) with Server= so using just (local)\SQLExpress
- // works for example, further parameters can still be appended using ;x=y
- $dsn .= 'Server=';
- // no break -> rest like ODBC
- case 'odbc':
- // for ODBC assume dbhost is a suitable DSN
- // e.g. Driver={SQL Server Native Client 10.0};Server=(local)\SQLExpress;
- $dsn .= $config['dbhost'];
-
- if ($use_db)
- {
- $dsn .= ';Database=' . $config['dbname'];
- }
- break;
-
- default:
- $dsn .= 'host=' . $config['dbhost'];
-
- if ($use_db)
- {
- $dsn .= ';dbname=' . $config['dbname'];
- }
- break;
- }
-
- $pdo = new PDO($dsn, $config['dbuser'], $config['dbpasswd']);;
-
- // good for debug
- // $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-
- return $pdo;
- }
-
- private function recreate_db($config, $dbms)
- {
- switch ($config['dbms'])
- {
- case 'sqlite':
- if (file_exists($config['dbhost']))
- {
- unlink($config['dbhost']);
- }
- break;
-
- default:
- $pdo = $this->new_pdo($config, $dbms, false);
-
- try
- {
- $pdo->exec('DROP DATABASE ' . $config['dbname']);
- }
- catch (PDOException $e)
- {
- // try to delete all tables if dropping the database was not possible.
- foreach ($this->get_tables() as $table)
- {
- try
- {
- $pdo->exec('DROP TABLE ' . $table);
- }
- catch (PDOException $e){} // ignore non-existent tables
- }
- }
-
- $pdo->exec('CREATE DATABASE ' . $config['dbname']);
- break;
- }
- }
-
- private function load_schema($pdo, $config, $dbms)
- {
- if ($config['dbms'] == 'mysql')
- {
- $sth = $pdo->query('SELECT VERSION() AS version');
- $row = $sth->fetch(PDO::FETCH_ASSOC);
-
- if (version_compare($row['version'], '4.1.3', '>='))
- {
- $dbms['SCHEMA'] .= '_41';
- }
- else
- {
- $dbms['SCHEMA'] .= '_40';
- }
- }
-
- $sql = $this->split_sql_file(file_get_contents(__DIR__ . "/../../phpBB/install/schemas/{$dbms['SCHEMA']}_schema.sql"), $config['dbms']);
-
- foreach ($sql as $query)
- {
- $pdo->exec($query);
- }
- }
-
public function getConnection()
{
$config = $this->get_database_config();
- $dbms = $this->get_dbms_data($config['dbms']);
+
+ $manager = $this->create_connection_manager($config);
if (!self::$already_connected)
{
- $this->recreate_db($config, $dbms);
+ $manager->recreate_db();
}
- $pdo = $this->new_pdo($config, $dbms, true);
+ $manager->connect();
if (!self::$already_connected)
{
- $this->load_schema($pdo, $config, $dbms);
-
+ $manager->load_schema();
self::$already_connected = true;
}
- return $this->createDefaultDBConnection($pdo, 'testdb');
+ return $this->createDefaultDBConnection($manager->get_pdo(), 'testdb');
}
public function new_dbal()
@@ -376,7 +110,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
$config = $this->get_database_config();
- require_once __DIR__ . '/../../phpBB/includes/db/' . $config['dbms'] . '.php';
+ require_once dirname(__FILE__) . '/../../phpBB/includes/db/' . $config['dbms'] . '.php';
$dbal = 'dbal_' . $config['dbms'];
$db = new $dbal();
$db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport']);
@@ -399,4 +133,9 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
{
$this->get_test_case_helpers()->setExpectedTriggerError($errno, $message);
}
+
+ protected function create_connection_manager($config)
+ {
+ return new phpbb_database_test_connection_manager($config);
+ }
}
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
new file mode 100644
index 0000000000..6c06857fbc
--- /dev/null
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -0,0 +1,346 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+class phpbb_database_test_connection_manager
+{
+ private $config;
+ private $dbms;
+ private $pdo;
+
+ /**
+ * Constructor
+ *
+ * @param array $config Tests database configuration as returned by
+ * phpbb_database_test_case::get_database_config()
+ */
+ public function __construct($config)
+ {
+ $this->config = $config;
+ $this->dbms = $this->get_dbms_data($this->config['dbms']);
+ }
+
+ /**
+ * Return the current PDO instance
+ */
+ public function get_pdo()
+ {
+ return $this->pdo;
+ }
+
+ /**
+ * Creates a PDO connection for the configured database.
+ *
+ * @param bool $use_db Whether the DSN should be tied to a
+ * particular database making it impossible
+ * to delete that database.
+ */
+ public function connect($use_db = true)
+ {
+ $dsn = $this->dbms['PDO'] . ':';
+
+ switch ($this->dbms['PDO'])
+ {
+ case 'sqlite2':
+ $dsn .= $this->config['dbhost'];
+ break;
+
+ case 'sqlsrv':
+ // prefix the hostname (or DSN) with Server= so using just (local)\SQLExpress
+ // works for example, further parameters can still be appended using ;x=y
+ $dsn .= 'Server=';
+ // no break -> rest like ODBC
+ case 'odbc':
+ // for ODBC assume dbhost is a suitable DSN
+ // e.g. Driver={SQL Server Native Client 10.0};Server=(local)\SQLExpress;
+ $dsn .= $this->config['dbhost'];
+
+ if ($use_db)
+ {
+ $dsn .= ';Database=' . $this->config['dbname'];
+ }
+ break;
+
+ default:
+ $dsn .= 'host=' . $this->config['dbhost'];
+
+ if ($use_db)
+ {
+ $dsn .= ';dbname=' . $this->config['dbname'];
+ }
+ break;
+ }
+
+ try
+ {
+ $this->pdo = new PDO($dsn, $this->config['dbuser'], $this->config['dbpasswd']);
+ }
+ catch (PDOException $e)
+ {
+ $cleaned_dsn = str_replace($this->config['dbpasswd'], '*password*', $dsn);
+ throw new Exception("Unable do connect to $cleaned_dsn using PDO with error: {$e->getMessage()}");
+ }
+
+ // good for debug
+ // $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ }
+
+ /**
+ * Load the phpBB database schema into the database
+ */
+ public function load_schema()
+ {
+ $this->ensure_connected(__METHOD__);
+
+ $directory = dirname(__FILE__) . '/../../phpBB/install/schemas/';
+ $this->load_schema_from_file($directory);
+ }
+
+ /**
+ * Drop the database if it exists and re-create it
+ *
+ * Note: This does not load the schema, and it is suggested
+ * to re-connect after calling to get use_db isolation.
+ */
+ public function recreate_db()
+ {
+ switch ($this->config['dbms'])
+ {
+ case 'sqlite':
+ if (file_exists($this->config['dbhost']))
+ {
+ unlink($this->config['dbhost']);
+ }
+ break;
+
+ default:
+ $this->connect(false);
+
+ try
+ {
+ $this->pdo->exec('DROP DATABASE ' . $config['dbname']);
+ }
+ catch (PDOException $e)
+ {
+ // try to delete all tables if dropping the database was not possible.
+ foreach ($this->get_tables() as $table)
+ {
+ $this->pdo->exec('DROP TABLE ' . $table);
+ }
+ }
+
+ $this->pdo->exec('CREATE DATABASE ' . $this->config['dbname']);
+ break;
+ }
+ }
+
+ /**
+ * Retrieves a list of all tables from the database.
+ *
+ * @return array(string)
+ */
+ public function get_tables()
+ {
+ $this->ensure_connected(__METHOD__);
+
+ switch ($this->config['dbms'])
+ {
+ case 'mysql':
+ case 'mysql4':
+ case 'mysqli':
+ $sql = 'SHOW TABLES';
+ break;
+
+ case 'sqlite':
+ $sql = 'SELECT name
+ FROM sqlite_master
+ WHERE type = "table"';
+ break;
+
+ case 'mssql':
+ case 'mssql_odbc':
+ case 'mssqlnative':
+ $sql = "SELECT name
+ FROM sysobjects
+ WHERE type='U'";
+ break;
+
+ case 'postgres':
+ $sql = 'SELECT relname
+ FROM pg_stat_user_tables';
+ break;
+
+ case 'firebird':
+ $sql = 'SELECT rdb$relation_name
+ FROM rdb$relations
+ WHERE rdb$view_source is null
+ AND rdb$system_flag = 0';
+ break;
+
+ case 'oracle':
+ $sql = 'SELECT table_name
+ FROM USER_TABLES';
+ break;
+ }
+
+ $result = $this->pdo->query($sql);
+
+ $tables = array();
+ while ($row = $result->fetch(PDO::FETCH_NUM))
+ {
+ $tables[] = current($row);
+ }
+
+ return $tables;
+ }
+
+ /**
+ * Throw an exception if not connected
+ */
+ protected function ensure_connected($method_name)
+ {
+ if (null === $this->pdo)
+ {
+ throw new Exception(sprintf('You must connect before calling %s', $method_name));
+ }
+ }
+
+ /**
+ * Compile the correct schema filename (as per create_schema_files) and
+ * load it into the database.
+ */
+ protected function load_schema_from_file($directory)
+ {
+ $schema = $this->dbms['SCHEMA'];
+
+ if ($this->config['dbms'] == 'mysql')
+ {
+ $sth = $this->pdo->query('SELECT VERSION() AS version');
+ $row = $sth->fetch(PDO::FETCH_ASSOC);
+
+ if (version_compare($row['version'], '4.1.3', '>='))
+ {
+ $schema .= '_41';
+ }
+ else
+ {
+ $schema .= '_40';
+ }
+ }
+
+ $filename = $directory . $schema . '_schema.sql';
+ $sql = $this->split_sql(file_get_contents($filename));
+
+ foreach ($sql as $query)
+ {
+ $this->pdo->exec($query);
+ }
+ }
+
+ /**
+ * Split contents of an SQL file into an array of SQL statements
+ *
+ * Note: This method is not the same as split_sql_file from functions_install.
+ *
+ * @param string $sql Raw contents of an SQL file
+ *
+ * @return Array of runnable SQL statements
+ */
+ protected function split_sql($sql)
+ {
+ $sql = str_replace("\r" , '', $sql);
+ $data = preg_split('/' . preg_quote($this->dbms['DELIM'], '/') . '$/m', $sql);
+
+ $data = array_map('trim', $data);
+
+ // The empty case
+ $end_data = end($data);
+
+ if (empty($end_data))
+ {
+ unset($data[key($data)]);
+ }
+
+ if ($this->config['dbms'] == 'sqlite')
+ {
+ // remove comment lines starting with # - they are not proper sqlite
+ // syntax and break sqlite2
+ foreach ($data as $i => $query)
+ {
+ $data[$i] = preg_replace('/^#.*$/m', "\n", $query);
+ }
+ }
+
+ return $data;
+ }
+
+ /**
+ * Map a phpBB dbms driver name to dbms data array
+ */
+ protected function get_dbms_data($dbms)
+ {
+ $available_dbms = array(
+ 'firebird' => array(
+ 'SCHEMA' => 'firebird',
+ 'DELIM' => ';;',
+ 'PDO' => 'firebird',
+ ),
+ 'mysqli' => array(
+ 'SCHEMA' => 'mysql_41',
+ 'DELIM' => ';',
+ 'PDO' => 'mysql',
+ ),
+ 'mysql' => array(
+ 'SCHEMA' => 'mysql',
+ 'DELIM' => ';',
+ 'PDO' => 'mysql',
+ ),
+ 'mssql' => array(
+ 'SCHEMA' => 'mssql',
+ 'DELIM' => 'GO',
+ 'PDO' => 'odbc',
+ ),
+ 'mssql_odbc'=> array(
+ 'SCHEMA' => 'mssql',
+ 'DELIM' => 'GO',
+ 'PDO' => 'odbc',
+ ),
+ 'mssqlnative' => array(
+ 'SCHEMA' => 'mssql',
+ 'DELIM' => 'GO',
+ 'PDO' => 'sqlsrv',
+ ),
+ 'oracle' => array(
+ 'SCHEMA' => 'oracle',
+ 'DELIM' => '/',
+ 'PDO' => 'oci',
+ ),
+ 'postgres' => array(
+ 'SCHEMA' => 'postgres',
+ 'DELIM' => ';',
+ 'PDO' => 'pgsql',
+ ),
+ 'sqlite' => array(
+ 'SCHEMA' => 'sqlite',
+ 'DELIM' => ';',
+ 'PDO' => 'sqlite2',
+ ),
+ );
+
+ if (isset($available_dbms[$dbms]))
+ {
+ return $available_dbms[$dbms];
+ }
+ else
+ {
+ $message = "Supplied dbms \"$dbms\" is not a valid phpBB dbms, must be one of: ";
+ $message .= implode(', ', array_keys($available_dbms));
+ throw new Exception($message);
+ }
+ }
+}
diff --git a/tests/text_processing/make_clickable_test.php b/tests/text_processing/make_clickable_test.php
index 75a35daf82..29b982d709 100644
--- a/tests/text_processing/make_clickable_test.php
+++ b/tests/text_processing/make_clickable_test.php
@@ -7,8 +7,8 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions.php';
-require_once __DIR__ . '/../../phpBB/includes/functions_content.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
class phpbb_text_processing_make_clickable_test extends phpbb_test_case
{
diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php
new file mode 100644
index 0000000000..6c60583a7b
--- /dev/null
+++ b/tests/user/lang_test.php
@@ -0,0 +1,58 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/session.php';
+
+class phpbb_user_lang_test extends phpbb_test_case
+{
+ public function test_user_lang_sprintf()
+ {
+ $user = new user;
+ $user->lang = array(
+ 'FOO' => 'BAR',
+ 'BARZ' => 'PENG',
+ 'EMPTY' => '',
+ 'ZERO' => '0',
+ 'STR' => '%d %s, %d topics',
+ 'STR2' => '%d foos',
+ 'ARRY' => array(
+ 0 => 'No posts', // 0
+ 1 => '1 post', // 1
+ 2 => '%d posts', // 2+
+ ),
+ );
+
+ // No param
+ $this->assertEquals($user->lang('FOO'), 'BAR');
+ $this->assertEquals($user->lang('EMPTY'), '');
+ $this->assertEquals($user->lang('ZERO'), '0');
+
+ // Invalid index
+ $this->assertEquals($user->lang('VOID'), 'VOID');
+
+ // Unnecessary param
+ $this->assertEquals($user->lang('FOO', 2), 'BAR');
+ $this->assertEquals($user->lang('FOO', 2, 3), 'BAR');
+ $this->assertEquals($user->lang('FOO', 2, 3, 'BARZ'), 'BAR');
+
+ // String
+ $this->assertEquals($user->lang('STR', 24, 'x', 42), '24 x, 42 topics');
+ $this->assertEquals($user->lang('STR2', 64), '64 foos');
+
+ // Array
+ $this->assertEquals($user->lang('ARRY', 0), 'No posts');
+ $this->assertEquals($user->lang('ARRY', 1), '1 post');
+ $this->assertEquals($user->lang('ARRY', 2), '2 posts');
+ $this->assertEquals($user->lang('ARRY', 123), '123 posts');
+
+ // Bug PHPBB3-9949
+ $this->assertEquals($user->lang('ARRY', 1, 2), '1 post');
+ $this->assertEquals($user->lang('ARRY', 1, 's', 2), '1 post');
+ }
+}
diff --git a/tests/utf/normalizer_test.php b/tests/utf/normalizer_test.php
index 9a9011c0fe..38b4ec1b6b 100644
--- a/tests/utf/normalizer_test.php
+++ b/tests/utf/normalizer_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/utf/utf_normalizer.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_normalizer.php';
/**
* @group slow
@@ -16,8 +16,8 @@ class phpbb_utf_normalizer_test extends phpbb_test_case
{
static public function setUpBeforeClass()
{
- self::download('http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt', __DIR__.'/data');
- self::download('http://www.unicode.org/Public/UNIDATA/UnicodeData.txt', __DIR__.'/data');
+ 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');
}
public function test_normalizer()
@@ -62,7 +62,7 @@ class phpbb_utf_normalizer_test extends phpbb_test_case
$tested_chars = array();
- $fp = fopen(__DIR__.'/data/NormalizationTest.txt', 'rb');
+ $fp = fopen(dirname(__FILE__).'/data/NormalizationTest.txt', 'rb');
while (!feof($fp))
{
$line = fgets($fp);
@@ -117,7 +117,7 @@ class phpbb_utf_normalizer_test extends phpbb_test_case
*/
public function test_invariants(array $tested_chars)
{
- $fp = fopen(__DIR__.'/data/UnicodeData.txt', 'rb');
+ $fp = fopen(dirname(__FILE__).'/data/UnicodeData.txt', 'rb');
while (!feof($fp))
{
diff --git a/tests/utf/utf8_clean_string_test.php b/tests/utf/utf8_clean_string_test.php
index 148297ad4b..e5a771eafa 100644
--- a/tests/utf/utf8_clean_string_test.php
+++ b/tests/utf/utf8_clean_string_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
class phpbb_utf_utf8_clean_string_test extends phpbb_test_case
{
diff --git a/tests/utf/utf8_wordwrap_test.php b/tests/utf/utf8_wordwrap_test.php
index fbc947b92a..03fa9dc38c 100644
--- a/tests/utf/utf8_wordwrap_test.php
+++ b/tests/utf/utf8_wordwrap_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
class phpbb_utf_utf8_wordwrap_test extends phpbb_test_case
{