aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--phpBB/docs/AUTHORS3
-rw-r--r--phpBB/download/file.php14
-rw-r--r--phpBB/includes/acp/acp_board.php1
-rw-r--r--phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php5
-rw-r--r--phpBB/includes/functions.php9
-rw-r--r--phpBB/includes/functions_posting.php2
-rw-r--r--phpBB/includes/mcp/mcp_queue.php2
-rw-r--r--phpBB/includes/session.php17
-rw-r--r--phpBB/install/convertors/functions_phpbb20.php2
-rw-r--r--phpBB/install/database_update.php4
-rw-r--r--phpBB/install/install_install.php1
-rw-r--r--phpBB/install/schemas/schema_data.sql1
-rw-r--r--phpBB/language/en/acp/board.php1
-rw-r--r--phpBB/language/en/search.php1
-rw-r--r--phpBB/posting.php23
-rw-r--r--phpBB/search.php16
-rw-r--r--phpBB/styles/prosilver/template/index_body.html2
-rw-r--r--phpBB/styles/subsilver2/template/overall_header.html2
-rw-r--r--phpBB/ucp.php2
-rw-r--r--tests/dbal/dbal.php5
-rw-r--r--tests/test_framework/phpbb_database_test_case.php59
-rw-r--r--tests/test_framework/phpbb_test_case_helpers.php37
23 files changed, 148 insertions, 65 deletions
diff --git a/.gitignore b/.gitignore
index 3e0f454e0c..2b9eef7fce 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
phpBB/cache/*.php
-*~ \ No newline at end of file
+tests/phpbb_unit_tests.sqlite2
+tests/test_config.php
+*~
diff --git a/phpBB/docs/AUTHORS b/phpBB/docs/AUTHORS
index 84677c4e15..b3166313c3 100644
--- a/phpBB/docs/AUTHORS
+++ b/phpBB/docs/AUTHORS
@@ -26,8 +26,8 @@ phpBB Developers: A_Jelly_Doughnut (Josh Woody)
Acyd Burn (Meik Sievertsen) [Lead 09/2005 - 01/2010]
APTX (Marek A. R.)
bantu (Andreas Fischer)
- DavidMJ (David M.)
dhn (Dominik Dröscher)
+ igorw (Igor Wiedler)
kellanved (Henry Sudhof)
nickvergessen (Joas Schilling)
rxu (Ruslan Uzdenov)
@@ -49,6 +49,7 @@ phpBB Lead Developer: psoTFX (Paul S. Owen) [2001 - 09/2005]
phpBB Developers: Ashe (Ludovic Arnaud) [10/2002 - 11/2003, 06/2006 - 10/2006]
BartVB (Bart van Bragt) [11/2000 - 03/2006]
+ DavidMJ (David M.) [12/2005 - 08/2009]
GrahamJE (Graham Eames) [09/2005 - 11/2006]
Vic D'Elfant (Vic D'Elfant) [04/2007 - 04/2009]
diff --git a/phpBB/download/file.php b/phpBB/download/file.php
index 1f2cee4d95..5f45b88359 100644
--- a/phpBB/download/file.php
+++ b/phpBB/download/file.php
@@ -77,7 +77,7 @@ if (isset($_GET['avatar']))
// '==' is not a bug - . as the first char is as bad as no dot at all
if (strpos($filename, '.') == false)
{
- header('HTTP/1.0 403 Forbidden');
+ send_status_line(403, 'Forbidden');
$exit = true;
}
@@ -91,7 +91,7 @@ if (isset($_GET['avatar']))
if (!$exit && !in_array($ext, array('png', 'gif', 'jpg', 'jpeg')))
{
// no way such an avatar could exist. They are not following the rules, stop the show.
- header("HTTP/1.0 403 Forbidden");
+ send_status_line(403, 'Forbidden');
$exit = true;
}
@@ -101,7 +101,7 @@ if (isset($_GET['avatar']))
if (!$filename)
{
// no way such an avatar could exist. They are not following the rules, stop the show.
- header("HTTP/1.0 403 Forbidden");
+ send_status_line(403, 'Forbidden');
}
else
{
@@ -199,7 +199,7 @@ else
$row['forum_id'] = false;
if (!$auth->acl_get('u_pm_download'))
{
- header('HTTP/1.0 403 Forbidden');
+ send_status_line(403, 'Forbidden');
trigger_error('SORRY_AUTH_VIEW_ATTACH');
}
@@ -222,7 +222,7 @@ else
if (!$allowed)
{
- header('HTTP/1.0 403 Forbidden');
+ send_status_line(403, 'Forbidden');
trigger_error('ERROR_NO_ATTACHMENT');
}
}
@@ -237,7 +237,7 @@ else
if (!download_allowed())
{
- header('HTTP/1.0 403 Forbidden');
+ send_status_line(403, 'Forbidden');
trigger_error($user->lang['LINKAGE_FORBIDDEN']);
}
@@ -383,7 +383,7 @@ function send_avatar_to_browser($file, $browser)
}
else
{
- header('HTTP/1.0 404 Not Found');
+ send_status_line(404, 'Not Found');
}
}
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index 927e72010e..a5e80e1f6d 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -319,6 +319,7 @@ class acp_board
'load_online_guests' => array('lang' => 'YES_ONLINE_GUESTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'load_onlinetrack' => array('lang' => 'YES_ONLINE_TRACK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'load_birthdays' => array('lang' => 'YES_BIRTHDAYS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
+ 'load_unreads_search' => array('lang' => 'YES_UNREAD_SEARCH', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'load_moderators' => array('lang' => 'YES_MODERATORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'load_jumpbox' => array('lang' => 'YES_JUMPBOX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'load_user_activity' => array('lang' => 'LOAD_USER_ACTIVITY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
index 0f0bfc4156..ea171dbe2c 100644
--- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
+++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php
@@ -314,10 +314,7 @@ class phpbb_recaptcha extends phpbb_default_captcha
}
else
{
- if ($answers[1] === 'incorrect-captcha-sol')
- {
- return $user->lang['RECAPTCHA_INCORRECT'];
- }
+ return $user->lang['RECAPTCHA_INCORRECT'];
}
}
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index c4ff998e69..9aec98dce2 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -3753,7 +3753,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
}
// Do not send 200 OK, but service unavailable on errors
- header('HTTP/1.1 503 Service Unavailable');
+ send_status_line(503, 'Service Unavailable');
garbage_collection();
@@ -4223,7 +4223,8 @@ function phpbb_http_login($param)
}
else if ($auth_result['status'] == LOGIN_ERROR_ATTEMPTS)
{
- header('HTTP/1.0 401 Unauthorized');
+ send_status_line(401, 'Unauthorized');
+
trigger_error('NOT_AUTHORISED');
}
}
@@ -4235,7 +4236,7 @@ function phpbb_http_login($param)
$param['auth_message'] = preg_replace('/[\x80-\xFF]/', '?', $param['auth_message']);
header('WWW-Authenticate: Basic realm="' . $param['auth_message'] . '"');
- header('HTTP/1.0 401 Unauthorized');
+ send_status_line(401, 'Unauthorized');
trigger_error('NOT_AUTHORISED');
}
@@ -4465,6 +4466,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'S_ENABLE_FEEDS_TOPICS_ACTIVE' => ($config['feed_topics_active']) ? true : false,
'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false,
+ 'S_LOAD_UNREADS' => ($config['load_unreads_search']) ? true : false,
+
'T_THEME_PATH' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme',
'T_TEMPLATE_PATH' => "{$web_path}styles/" . $user->theme['template_path'] . '/template',
'T_SUPER_TEMPLATE_PATH' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? "{$web_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$web_path}styles/" . $user->theme['template_path'] . '/template',
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 5e25648eb8..6fd87db663 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -2583,7 +2583,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
}
// Send Notifications
- if ($mode != 'edit' && $mode != 'delete' && $post_approval)
+ if (($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_approval)
{
user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id']);
}
diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php
index e43881fab2..c419da5574 100644
--- a/phpBB/includes/mcp/mcp_queue.php
+++ b/phpBB/includes/mcp/mcp_queue.php
@@ -428,7 +428,7 @@ class mcp_queue
'POST_ID' => $row['post_id'],
'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'],
- 'POST_SUBJECT' => $row['post_subject'],
+ 'POST_SUBJECT' => ($row['post_subject'] != '') ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
'TOPIC_TITLE' => $row['topic_title'],
'POST_TIME' => $user->format_date($row['post_time']))
);
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 79023cc7bc..5f5b39fe27 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -285,6 +285,17 @@ class session
break;
}
+ // Quick check for IPv4-mapped address in IPv6
+ if (stripos($ip, '::ffff:') === 0)
+ {
+ $ipv4 = substr($ip, 7);
+
+ if (preg_match(get_preg_expression('ipv4'), $ipv4))
+ {
+ $ip = $ipv4;
+ }
+ }
+
// Use the last in chain
$this->ip = $ip;
}
@@ -748,7 +759,7 @@ class session
if ((int) $row['sessions'] > (int) $config['active_sessions'])
{
- header('HTTP/1.1 503 Service Unavailable');
+ send_status_line(503, 'Service Unavailable');
trigger_error('BOARD_UNAVAILABLE');
}
}
@@ -1821,7 +1832,7 @@ class user extends session
{
if ($this->data['is_bot'])
{
- header('HTTP/1.1 503 Service Unavailable');
+ send_status_line(503, 'Service Unavailable');
}
$message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE';
@@ -1840,7 +1851,7 @@ class user extends session
{
if ($this->data['is_bot'])
{
- header('HTTP/1.1 503 Service Unavailable');
+ send_status_line(503, 'Service Unavailable');
}
trigger_error('BOARD_UNAVAILABLE');
}
diff --git a/phpBB/install/convertors/functions_phpbb20.php b/phpBB/install/convertors/functions_phpbb20.php
index b80c7673e3..78224dd5da 100644
--- a/phpBB/install/convertors/functions_phpbb20.php
+++ b/phpBB/install/convertors/functions_phpbb20.php
@@ -1239,9 +1239,9 @@ function phpbb_prepare_message($message)
// Already the new user id ;)
$user_id = $convert->row['poster_id'];
+ $message = str_replace('<br />', "\n", $message);
$message = str_replace('<', '&lt;', $message);
$message = str_replace('>', '&gt;', $message);
- $message = str_replace('<br />', "\n", $message);
// make the post UTF-8
$message = phpbb_set_encoding($message);
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index 019469b061..ca4ef817be 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -119,6 +119,7 @@ $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
unset($dbpasswd);
$user->ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : '';
+$user->ip = (stripos($user->ip, '::ffff:') === 0) ? substr($user->ip, 7) : $user->ip;
$sql = "SELECT config_value
FROM " . CONFIG_TABLE . "
@@ -1795,6 +1796,9 @@ function change_database_data(&$no_updates, $version)
// Sync the forums we have deleted shadow topics from.
sync('forum', 'forum_id', $sync_forum_ids, true, true);
+ // Unread posts search load switch
+ set_config('load_unreads_search', '1');
+
$no_updates = false;
break;
}
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index 6c23460de9..2dd58584f4 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -1236,6 +1236,7 @@ class install_install extends module
$current_time = time();
$user_ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : '';
+ $user_ip = (stripos($user_ip, '::ffff:') === 0) ? substr($user_ip, 7) : $user_ip;
if ($data['script_path'] !== '/')
{
diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index e815615eef..a25b68ba39 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -168,6 +168,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_time',
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_onlinetrack', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_search', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_tplcompile', '0');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_unreads_search', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_user_activity', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments', '3');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments_pm', '1');
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index ac0ddf1b73..77deba6e19 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -375,6 +375,7 @@ $lang = array_merge($lang, array(
'YES_POST_MARKING_EXPLAIN' => 'Indicates whether user has posted to a topic.',
'YES_READ_MARKING' => 'Enable server-side topic marking',
'YES_READ_MARKING_EXPLAIN' => 'Stores read/unread status information in the database rather than a cookie.',
+ 'YES_UNREAD_SEARCH' => 'Enable search for unread posts',
));
// Auth settings
diff --git a/phpBB/language/en/search.php b/phpBB/language/en/search.php
index be92391a4e..d93fe6b56a 100644
--- a/phpBB/language/en/search.php
+++ b/phpBB/language/en/search.php
@@ -62,6 +62,7 @@ $lang = array_merge($lang, array(
'NO_SEARCH' => 'Sorry but you are not permitted to use the search system.',
'NO_SEARCH_RESULTS' => 'No suitable matches were found.',
'NO_SEARCH_TIME' => 'Sorry but you cannot use search at this time. Please try again in a few minutes.',
+ 'NO_SEARCH_UNREADS' => 'Sorry but searching for unread posts has been disabled on this board.',
'WORD_IN_NO_POST' => 'No posts were found because the word <strong>%s</strong> is not contained in any post.',
'WORDS_IN_NO_POST' => 'No posts were found because the words <strong>%s</strong> are not contained in any post.',
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 8cacac2910..853ac18aad 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -402,15 +402,18 @@ if ($post_data['poll_start'])
$db->sql_freeresult($result);
}
-$original_poll_data = array(
- 'poll_title' => $post_data['poll_title'],
- 'poll_length' => $post_data['poll_length'],
- 'poll_max_options' => $post_data['poll_max_options'],
- 'poll_option_text' => implode("\n", $post_data['poll_options']),
- 'poll_start' => $post_data['poll_start'],
- 'poll_last_vote' => $post_data['poll_last_vote'],
- 'poll_vote_change' => $post_data['poll_vote_change'],
-);
+if ($mode == 'edit')
+{
+ $original_poll_data = array(
+ 'poll_title' => $post_data['poll_title'],
+ 'poll_length' => $post_data['poll_length'],
+ 'poll_max_options' => $post_data['poll_max_options'],
+ 'poll_option_text' => implode("\n", $post_data['poll_options']),
+ 'poll_start' => $post_data['poll_start'],
+ 'poll_last_vote' => $post_data['poll_last_vote'],
+ 'poll_vote_change' => $post_data['poll_vote_change'],
+ );
+}
$orig_poll_options_size = sizeof($post_data['poll_options']);
@@ -1297,7 +1300,7 @@ $attachment_data = $message_parser->attachment_data;
$filename_data = $message_parser->filename_data;
$post_data['post_text'] = $message_parser->message;
-if (sizeof($post_data['poll_options']) && $post_data['poll_title'])
+if (sizeof($post_data['poll_options']) || $post_data['poll_title'])
{
$message_parser->message = $post_data['poll_title'];
$message_parser->bbcode_uid = $post_data['bbcode_uid'];
diff --git a/phpBB/search.php b/phpBB/search.php
index 96f320fe9f..2a13e20477 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -61,10 +61,18 @@ if ($search_id == 'egosearch')
}
}
-// Search for unread posts needs user to be logged in if topics tracking for guests is disabled
-if ($search_id == 'unreadposts' && !$config['load_anon_lastread'] && !$user->data['is_registered'])
+// Search for unread posts needs to be allowed and user to be logged in if topics tracking for guests is disabled
+if ($search_id == 'unreadposts')
{
- login_box('', $user->lang['LOGIN_EXPLAIN_UNREADSEARCH']);
+ if (!$config['load_unreads_search'])
+ {
+ $template->assign_var('S_NO_SEARCH', true);
+ trigger_error('NO_SEARCH_UNREADS');
+ }
+ else if (!$config['load_anon_lastread'] && !$user->data['is_registered'])
+ {
+ login_box('', $user->lang['LOGIN_EXPLAIN_UNREADSEARCH']);
+ }
}
// Is user able to search? Has search been disabled?
@@ -892,7 +900,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
'S_TOPIC_GLOBAL' => (!$forum_id) ? true : false,
'S_TOPIC_TYPE' => $row['topic_type'],
- 'S_USER_POSTED' => (!empty($row['mark_type'])) ? true : false,
+ 'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false,
'S_UNREAD_TOPIC' => $unread_topic,
'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $forum_id)) ? true : false,
diff --git a/phpBB/styles/prosilver/template/index_body.html b/phpBB/styles/prosilver/template/index_body.html
index 17790eb78a..af2077141c 100644
--- a/phpBB/styles/prosilver/template/index_body.html
+++ b/phpBB/styles/prosilver/template/index_body.html
@@ -6,7 +6,7 @@
<!-- IF S_DISPLAY_SEARCH or (S_USER_LOGGED_IN and not S_IS_BOT) -->
<ul class="linklist">
<!-- IF S_DISPLAY_SEARCH -->
- <li><a href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a><!-- IF S_USER_LOGGED_IN --> &bull; <a href="{U_SEARCH_UNREAD}">{L_SEARCH_UNREAD}</a> &bull; <a href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a><!-- ENDIF --> &bull; <a href="{U_SEARCH_ACTIVE_TOPICS}">{L_SEARCH_ACTIVE_TOPICS}</a></li>
+ <li><a href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a><!-- IF S_USER_LOGGED_IN --><!-- IF S_LOAD_UNREADS --> &bull; <a href="{U_SEARCH_UNREAD}">{L_SEARCH_UNREAD}</a><!-- ENDIF --> &bull; <a href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a><!-- ENDIF --> &bull; <a href="{U_SEARCH_ACTIVE_TOPICS}">{L_SEARCH_ACTIVE_TOPICS}</a></li>
<!-- ENDIF -->
<!-- IF not S_IS_BOT and U_MARK_FORUMS --><li class="rightside"><a href="{U_MARK_FORUMS}" accesskey="m">{L_MARK_FORUMS_READ}</a></li><!-- ENDIF -->
</ul>
diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html
index 963f5160dd..37691d4f1c 100644
--- a/phpBB/styles/subsilver2/template/overall_header.html
+++ b/phpBB/styles/subsilver2/template/overall_header.html
@@ -202,7 +202,7 @@ function marklist(id, name, state)
<p class="searchbar">
<span style="float: {S_CONTENT_FLOW_BEGIN};"><a href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a> | <a href="{U_SEARCH_ACTIVE_TOPICS}">{L_SEARCH_ACTIVE_TOPICS}</a></span>
<!-- IF S_USER_LOGGED_IN -->
- <span style="float: {S_CONTENT_FLOW_END};"><a href="{U_SEARCH_UNREAD}">{L_SEARCH_UNREAD}</a> | <a href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a> | <a href="{U_SEARCH_SELF}">{L_SEARCH_SELF}</a></span>
+ <span style="float: {S_CONTENT_FLOW_END};"><!-- IF S_LOAD_UNREADS --><a href="{U_SEARCH_UNREAD}">{L_SEARCH_UNREAD}</a> | <!-- ENDIF --><a href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a> | <a href="{U_SEARCH_SELF}">{L_SEARCH_SELF}</a></span>
<!-- ENDIF -->
</p>
<!-- ENDIF -->
diff --git a/phpBB/ucp.php b/phpBB/ucp.php
index 994fe064a1..f5a2ec9648 100644
--- a/phpBB/ucp.php
+++ b/phpBB/ucp.php
@@ -22,7 +22,7 @@ require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
$id = request_var('i', '');
$mode = request_var('mode', '');
-if ($mode == 'login' || $mode == 'logout' || $mode == 'confirm')
+if (in_array($mode, array('login', 'logout', 'confirm', 'sendpassword', 'activate')))
{
define('IN_LOGIN', true);
}
diff --git a/tests/dbal/dbal.php b/tests/dbal/dbal.php
index 1cce891ca9..663323ad61 100644
--- a/tests/dbal/dbal.php
+++ b/tests/dbal/dbal.php
@@ -244,8 +244,9 @@ class phpbb_dbal_test extends phpbb_database_test_case
array('username_clean' => 'bertie'))),
// These here would throw errors and therefor $result should be false.
- array('user_id', array(), false, false, false, true),
- array('user_id', array(), true, false, false, true),
+ // Removing for now because SQLite accepts empty IN() syntax
+ /*array('user_id', array(), false, false, false, true),
+ array('user_id', array(), true, false, false, true),*/
);
}
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index d558874c6f..f6bf420ebc 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -19,7 +19,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
}
}
- function get_dbms_data($dbms)
+ public function get_dbms_data($dbms)
{
$available_dbms = array(
'firebird' => array(
@@ -65,7 +65,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
'sqlite' => array(
'SCHEMA' => 'sqlite',
'DELIM' => ';',
- 'PDO' => 'sqlite',
+ 'PDO' => 'sqlite2',
),
);
@@ -79,10 +79,13 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
}
}
- function split_sql_file($sql, $delimiter)
+ // 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($delimiter, '/') . '$/m', $sql);
+ $data = preg_split('/' . preg_quote($dbms_data['DELIM'], '/') . '$/m', $sql);
$data = array_map('trim', $data);
@@ -94,6 +97,15 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
unset($data[key($data)]);
}
+ if ($dbms == 'sqlite')
+ {
+ // trim # off query to satisfy sqlite
+ foreach ($data as $i => $query)
+ {
+ $data[$i] = preg_replace('/^#.*$/m', "\n", $query);
+ }
+ }
+
return $data;
}
@@ -108,21 +120,42 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
if ($already_connected)
{
- $pdo = new PDO($dbms_data['PDO'] . ':host=' . $database_config['dbhost'] . ';dbname=' . $database_config['dbname'], $database_config['dbuser'], $database_config['dbpasswd']);
+ if ($database_config['dbms'] == 'sqlite')
+ {
+ $pdo = new PDO($dbms_data['PDO'] . ':' . $database_config['dbhost']);
+ }
+ else
+ {
+ $pdo = new PDO($dbms_data['PDO'] . ':host=' . $database_config['dbhost'] . ';dbname=' . $database_config['dbname'], $database_config['dbuser'], $database_config['dbpasswd']);
+ }
}
else
{
- $pdo = new PDO($dbms_data['PDO'] . ':host=' . $database_config['dbhost'] . ';', $database_config['dbuser'], $database_config['dbpasswd']);
-
- try
+ if ($database_config['dbms'] == 'sqlite')
{
- $pdo->exec('DROP DATABASE ' . $database_config['dbname']);
+ // delete existing database
+ if (file_exists($database_config['dbhost']))
+ {
+ unlink($database_config['dbhost']);
+ }
+
+ $pdo = new PDO($dbms_data['PDO'] . ':' . $database_config['dbhost']);
}
- catch (PDOException $e){} // ignore non existent db
+ else
+ {
+ $pdo = new PDO($dbms_data['PDO'] . ':host=' . $database_config['dbhost'] . ';', $database_config['dbuser'], $database_config['dbpasswd']);try
+ {
+ $pdo->exec('DROP DATABASE ' . $database_config['dbname']);
+ }
+ catch (PDOException $e){} // ignore non existent db
- $pdo->exec('CREATE DATABASE ' . $database_config['dbname']);
+ $pdo->exec('CREATE DATABASE ' . $database_config['dbname']);
+
+ $pdo = new PDO($dbms_data['PDO'] . ':host=' . $database_config['dbhost'] . ';dbname=' . $database_config['dbname'], $database_config['dbuser'], $database_config['dbpasswd']);
+ }
- $pdo = new PDO($dbms_data['PDO'] . ':host=' . $database_config['dbhost'] . ';dbname=' . $database_config['dbname'], $database_config['dbuser'], $database_config['dbpasswd']);
+ // good for debug
+ // $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if ($database_config['dbms'] == 'mysql')
{
@@ -141,7 +174,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
unset($row, $sth);
}
- $sql_query = $this->split_sql_file(file_get_contents("../phpBB/install/schemas/{$dbms_data['SCHEMA']}_schema.sql"), $dbms_data['DELIM']);
+ $sql_query = $this->split_sql_file(file_get_contents("../phpBB/install/schemas/{$dbms_data['SCHEMA']}_schema.sql"), $database_config['dbms']);
foreach ($sql_query as $sql)
{
diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php
index 0c5932e1ad..7c026e496e 100644
--- a/tests/test_framework/phpbb_test_case_helpers.php
+++ b/tests/test_framework/phpbb_test_case_helpers.php
@@ -22,7 +22,32 @@ class phpbb_test_case_helpers
{
static $show_error = true;
- if (!file_exists('test_config.php'))
+ if (file_exists('test_config.php'))
+ {
+ include('test_config.php');
+
+ return array(
+ 'dbms' => $dbms,
+ 'dbhost' => $dbhost,
+ 'dbport' => $dbport,
+ 'dbname' => $dbname,
+ 'dbuser' => $dbuser,
+ 'dbpasswd' => $dbpasswd,
+ );
+ }
+ else if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>='))
+ {
+ // Silently use sqlite
+ return array(
+ 'dbms' => 'sqlite',
+ 'dbhost' => 'phpbb_unit_tests.sqlite2', // filename
+ 'dbport' => '',
+ 'dbname' => '',
+ 'dbuser' => '',
+ 'dbpasswd' => '',
+ );
+ }
+ else
{
if ($show_error)
{
@@ -46,16 +71,6 @@ class phpbb_test_case_helpers
NOTE: The database is dropped and recreated with the phpbb-db-schema! Do NOT specify a database with important data.", E_USER_ERROR);
}
- include('test_config.php');
-
- return array(
- 'dbms' => $dbms,
- 'dbhost' => $dbhost,
- 'dbport' => $dbport,
- 'dbname' => $dbname,
- 'dbuser' => $dbuser,
- 'dbpasswd' => $dbpasswd,
- );
}
public function new_dbal()