diff options
-rwxr-xr-x | phpBB/bin/phpbbcli.php | 2 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_bbcodes.php | 2 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 2 | ||||
-rw-r--r-- | phpBB/includes/functions_admin.php | 6 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_front.php | 10 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_reports.php | 6 | ||||
-rw-r--r-- | phpBB/memberlist.php | 32 | ||||
-rw-r--r-- | phpBB/phpbb/db/tools.php | 5 | ||||
-rw-r--r-- | phpBB/phpbb/log/log.php | 4 | ||||
-rw-r--r-- | tests/log/add_test.php | 9 | ||||
-rw-r--r-- | tests/test_framework/phpbb_database_test_connection_manager.php | 15 |
11 files changed, 54 insertions, 39 deletions
diff --git a/phpBB/bin/phpbbcli.php b/phpBB/bin/phpbbcli.php index ca425ad0c4..239dd3932b 100755 --- a/phpBB/bin/phpbbcli.php +++ b/phpBB/bin/phpbbcli.php @@ -59,6 +59,8 @@ $phpbb_container->get('request')->enable_super_globals(); require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx); $user = $phpbb_container->get('user'); +$user->data['user_id'] = ANONYMOUS; +$user->ip = '127.0.0.1'; $user->add_lang('acp/common'); $user->add_lang('cli'); diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php index 35ac33882e..c98be241e9 100644 --- a/phpBB/includes/acp/acp_bbcodes.php +++ b/phpBB/includes/acp/acp_bbcodes.php @@ -370,7 +370,7 @@ class acp_bbcodes * * @event core.acp_bbcodes_display_form * @var string action Type of the action: modify|create - * @var string sql_ary The SQL array to get custom bbcode data + * @var array sql_ary The SQL array to get custom bbcode data * @var array template_data Array with form template data * @var string u_action The u_action link * @since 3.1.0-a3 diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index bb1e47ecf7..094b1fd364 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4283,7 +4283,7 @@ function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum' * @var string item Restrict online users to a certain * session item, e.g. forum for * session_forum_id - * @var string sql_ary SQL query to obtain users online data + * @var array sql_ary SQL query array to obtain users online data * @since 3.1.4-RC1 * @changed 3.1.7-RC1 Change sql query into array and adjust var accordingly. Allows extension authors the ability to adjust the sql_ary. */ diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 33cf55cc0b..b3641a2b45 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -3101,9 +3101,9 @@ function get_database_size() { $version = $row['mysql_version']; - if (preg_match('#(3\.23|[45]\.)#', $version)) + if (preg_match('#(3\.23|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria)#', $version)) { - $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name(); + $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name(); $sql = 'SHOW TABLE STATUS FROM ' . $db_name; @@ -3112,7 +3112,7 @@ function get_database_size() $database_size = 0; while ($row = $db->sql_fetchrow($result)) { - if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB'))) + if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB' || $row['Engine'] == 'Aria'))) { if ($table_prefix != '') { diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index cdf1abd8ff..5d8aa18c16 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -54,8 +54,8 @@ function mcp_front_view($id, $mode, $action) * Allow altering the query to get the number of unapproved posts * * @event core.mcp_front_queue_unapproved_total_before - * @var int sql_ary Query to get the total number of unapproved posts - * @var array forum_list List of forums to look for unapproved posts + * @var array sql_ary Query array to get the total number of unapproved posts + * @var array forum_list List of forums to look for unapproved posts * @since 3.1.5-RC1 */ $vars = array('sql_ary', 'forum_list'); @@ -179,7 +179,7 @@ function mcp_front_view($id, $mode, $action) * Alter sql query to count the number of reported posts * * @event core.mcp_front_reports_count_query_before - * @var int sql The query string used to get the number of reports that exist + * @var string sql The query string used to get the number of reports that exist * @var array forum_list List of forums that contain the posts * @since 3.1.5-RC1 */ @@ -226,8 +226,8 @@ function mcp_front_view($id, $mode, $action) * Alter sql query to get latest reported posts * * @event core.mcp_front_reports_listing_query_before - * @var int sql_ary Associative array with the query to be executed - * @var array forum_list List of forums that contain the posts + * @var array sql_ary Associative array with the query to be executed + * @var array forum_list List of forums that contain the posts * @since 3.1.0-RC3 */ $vars = array('sql_ary', 'forum_list'); diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index fa2fed842f..6bb606a990 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -95,7 +95,7 @@ class mcp_reports * * @event core.mcp_reports_report_details_query_before * @var array sql_ary The array in the format of the query builder with the query - * @var mixed forum_id The forum_id, the number in the f GET parameter + * @var int forum_id The forum_id, the number in the f GET parameter * @var int post_id The post_id of the report being viewed (if 0, it is meaningless) * @var int report_id The report_id of the report being viewed * @since 3.1.5-RC1 @@ -118,10 +118,10 @@ class mcp_reports * * @event core.mcp_reports_report_details_query_after * @var array sql_ary The array in the format of the query builder with the query that had been executted - * @var mixed forum_id The forum_id, the number in the f GET parameter + * @var int forum_id The forum_id, the number in the f GET parameter * @var int post_id The post_id of the report being viewed (if 0, it is meaningless) * @var int report_id The report_id of the report being viewed - * @var int report The query's resulting row. + * @var array report The query's resulting row. * @since 3.1.5-RC1 */ $vars = array( diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 6be44587f5..7cf39f4eb7 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1229,21 +1229,19 @@ switch ($mode) ); extract($phpbb_dispatcher->trigger_event('core.memberlist_modify_sql_query_data', compact($vars))); - // Count the users ... - if ($sql_where) - { - $sql = 'SELECT COUNT(u.user_id) AS total_users - FROM ' . USERS_TABLE . " u$sql_from - WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ") - $sql_where"; - $result = $db->sql_query($sql); - $total_users = (int) $db->sql_fetchfield('total_users'); - $db->sql_freeresult($result); - } - else + $user_types = array(USER_NORMAL, USER_FOUNDER); + if ($auth->acl_get('a_user')) { - $total_users = $config['num_users']; + $user_types[] = USER_INACTIVE; } + // Count the users ... + $sql = 'SELECT COUNT(u.user_id) AS total_users + FROM ' . USERS_TABLE . " u$sql_from + WHERE " . $db->sql_in_set('u.user_type', $user_types) . " + $sql_where"; + $result = $db->sql_query($sql); + $total_users = (int) $db->sql_fetchfield('total_users'); + $db->sql_freeresult($result); // Build a relevant pagination_url $params = $sort_params = array(); @@ -1409,13 +1407,7 @@ switch ($mode) ); } - $user_types = array(USER_NORMAL, USER_FOUNDER); - if ($auth->acl_get('a_user')) - { - $user_types[] = USER_INACTIVE; - } - - $start = $pagination->validate_start($start, $config['topics_per_page'], $config['num_users']); + $start = $pagination->validate_start($start, $config['topics_per_page'], $total_users); // Get us some users :D $sql = "SELECT u.user_id diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 775deccc30..e76e7b0e18 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -1533,6 +1533,11 @@ class tools } } + if (isset($column_data['after'])) + { + $return_array['after'] = $column_data['after']; + } + break; case 'oracle': diff --git a/phpBB/phpbb/log/log.php b/phpBB/phpbb/log/log.php index 3d995b4e4a..d46e3d1f3f 100644 --- a/phpBB/phpbb/log/log.php +++ b/phpBB/phpbb/log/log.php @@ -229,8 +229,8 @@ class log implements \phpbb\log\log_interface } $sql_ary = array( - 'user_id' => $user_id, - 'log_ip' => $log_ip, + 'user_id' => !empty($user_id) ? $user_id : ANONYMOUS, + 'log_ip' => !empty($log_ip) ? $log_ip : '', 'log_time' => $log_time, 'log_operation' => $log_operation, ); diff --git a/tests/log/add_test.php b/tests/log/add_test.php index bacc0c76f7..29d3adaeb6 100644 --- a/tests/log/add_test.php +++ b/tests/log/add_test.php @@ -88,5 +88,14 @@ class phpbb_log_add_test extends phpbb_database_test_case // Invalid mode specified $this->assertFalse($log->add('mode_does_not_exist', $user_id, $log_ip, $log_operation, $log_time)); + + // null user and null ip given + $this->assertEquals(3, $log->add($mode, null, null, $log_operation, $log_time), 'Adding log with null user_id and null user_ip failed'); + $sql = 'SELECT user_id, log_ip FROM ' . LOG_TABLE . ' WHERE log_id = 3'; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + $this->assertEquals(ANONYMOUS, $row['user_id'], 'Adding log with null user_id failed'); + $this->assertEquals('', $row['log_ip'], 'Adding log with null user_ip failed'); } } diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 5d643e43e2..3b5bab749e 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -85,11 +85,18 @@ class phpbb_database_test_connection_manager break; default: - $dsn .= 'host=' . $this->config['dbhost']; - - if ($this->config['dbport']) + if (!empty($this->config['dbport']) && !is_numeric($this->config['dbport']) && $this->dbms['PDO'] != 'pgsql') + { + $dsn .= 'unix_socket=' . $this->config['dbport']; + } + else { - $dsn .= ';port=' . $this->config['dbport']; + $dsn .= 'host=' . $this->config['dbhost']; + + if ($this->config['dbport']) + { + $dsn .= ';port=' . $this->config['dbport']; + } } if ($use_db) |