Permalink
Browse files

Merge remote-tracking branch 'github-nicofuma/ticket/12446' into deve…

…lop-ascraeus

* github-nicofuma/ticket/12446:
  [ticket/12446] Unnecessary db connect inphpbb_bootstrap_enabled_exts
  • Loading branch information...
2 parents 86e21a9 + ff6e026 commit 53ff23671c2706c13bbe8ecca6b29b3c3456768b @naderman naderman committed Jul 4, 2014
Showing with 764 additions and 143 deletions.
  1. +5 −0 phpBB/config/services.yml
  2. +1 −1 phpBB/develop/add_permissions.php
  3. +1 −1 phpBB/develop/benchmark.php
  4. +1 −1 phpBB/develop/merge_attachment_tables.php
  5. +2 −2 phpBB/develop/merge_post_tables.php
  6. +0 −5 phpBB/download/file.php
  7. +14 −14 phpBB/includes/acp/acp_database.php
  8. +1 −1 phpBB/includes/acp/acp_forums.php
  9. +1 −1 phpBB/includes/acp/acp_icons.php
  10. +2 −2 phpBB/includes/acp/acp_main.php
  11. +3 −3 phpBB/includes/acp/acp_permission_roles.php
  12. +1 −1 phpBB/includes/acp/acp_permissions.php
  13. +2 −2 phpBB/includes/acp/acp_profile.php
  14. +2 −2 phpBB/includes/acp/acp_prune.php
  15. +1 −1 phpBB/includes/acp/acp_reasons.php
  16. +2 −2 phpBB/includes/acp/acp_users.php
  17. +1 −1 phpBB/includes/acp/auth.php
  18. +2 −2 phpBB/includes/functions.php
  19. +8 −8 phpBB/includes/functions_admin.php
  20. +10 −4 phpBB/includes/functions_container.php
  21. +2 −2 phpBB/includes/functions_convert.php
  22. +1 −1 phpBB/includes/functions_install.php
  23. +1 −1 phpBB/includes/message_parser.php
  24. +4 −4 phpBB/install/convertors/functions_phpbb20.php
  25. +1 −1 phpBB/install/database_update.php
  26. +1 −1 phpBB/install/index.php
  27. +8 −8 phpBB/install/install_convert.php
  28. +16 −16 phpBB/install/install_install.php
  29. +6 −6 phpBB/memberlist.php
  30. +2 −2 phpBB/phpbb/auth/auth.php
  31. +1 −1 phpBB/phpbb/cache/service.php
  32. +96 −0 phpBB/phpbb/db/driver/driver.php
  33. +84 −0 phpBB/phpbb/db/driver/driver_interface.php
  34. +435 −0 phpBB/phpbb/db/driver/factory.php
  35. +1 −1 phpBB/phpbb/db/migration/data/v30x/local_url_bbcode.php
  36. +1 −1 phpBB/phpbb/db/migration/data/v30x/release_3_0_4.php
  37. +1 −1 phpBB/phpbb/db/migration/data/v30x/release_3_0_7_rc1.php
  38. +1 −1 phpBB/phpbb/db/migration/data/v30x/release_3_0_9_rc1.php
  39. +1 −1 phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php
  40. +1 −1 phpBB/phpbb/db/migration/data/v310/postgres_fulltext_drop.php
  41. +3 −3 phpBB/phpbb/db/migration/migration.php
  42. +1 −1 phpBB/phpbb/db/migrator.php
  43. +1 −1 phpBB/phpbb/db/sql_insert_buffer.php
  44. +4 −4 phpBB/phpbb/db/tools.php
  45. +1 −1 phpBB/phpbb/log/log.php
  46. +2 −2 phpBB/phpbb/search/base.php
  47. +4 −4 phpBB/phpbb/search/fulltext_mysql.php
  48. +5 −5 phpBB/phpbb/search/fulltext_native.php
  49. +4 −4 phpBB/phpbb/search/fulltext_postgres.php
  50. +3 −3 phpBB/phpbb/search/fulltext_sphinx.php
  51. +4 −4 phpBB/search.php
  52. +1 −1 phpBB/viewonline.php
  53. +1 −1 tests/dbal/order_lower_test.php
  54. +2 −2 tests/dbal/select_test.php
  55. +4 −4 tests/dbal/sql_insert_buffer_test.php
@@ -139,6 +139,11 @@ services:
- @service_container
dbal.conn:
+ class: phpbb\db\driver\factory
+ arguments:
+ - @service_container
+
+ dbal.conn.driver:
class: %dbal.driver.class%
calls:
- [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]]
@@ -371,7 +371,7 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting)
switch ($sql_type)
{
case 'insert':
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mysql':
case 'mysql4':
@@ -313,7 +313,7 @@ function make_post($new_topic_id, $forum_id, $user_id, $post_username, $text, $m
else
{
// Rollback
- if($db->sql_layer == "mysql")
+ if($db->get_sql_layer() == "mysql")
{
$sql = "DELETE FROM " . POSTS_TABLE . "
WHERE post_id = $new_post_id";
@@ -48,7 +48,7 @@
AND a.post_id = p.post_id";
$db->sql_query($sql);
-switch ($db->sql_layer)
+switch ($db->get_sql_layer())
{
case 'mysql':
case 'mysql4':
@@ -46,7 +46,7 @@
WHERE pt.post_id = p.post_id";
$db->sql_query($sql);
-switch ($db->sql_layer)
+switch ($db->get_sql_layer())
{
case 'mysql':
case 'mysql4':
@@ -142,7 +142,7 @@
}
$db->sql_freeresult($result);
-switch ($db->sql_layer)
+switch ($db->get_sql_layer())
{
case 'oracle':
$sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
@@ -75,11 +75,6 @@
$db = $phpbb_container->get('dbal.conn');
$phpbb_log = $phpbb_container->get('log');
- // Connect to DB
- if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false))
- {
- exit;
- }
unset($dbpasswd);
request_var('', 0, false, false, $request);
@@ -90,7 +90,7 @@ function main($id, $mode)
$time = time();
$filename = 'backup_' . $time . '_' . unique_id();
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mysqli':
case 'mysql4':
@@ -133,7 +133,7 @@ function main($id, $mode)
else
{
// We might wanna empty out all that junk :D
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
@@ -320,7 +320,7 @@ function main($id, $mode)
break;
}
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mysql':
case 'mysql4':
@@ -365,10 +365,10 @@ function main($id, $mode)
{
trigger_error($user->lang['RESTORE_FAILURE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
- pg_put_line($db->db_connect_id, $sub . "\n");
+ pg_put_line($db->get_db_connect_id(), $sub . "\n");
}
- pg_put_line($db->db_connect_id, "\\.\n");
- pg_end_copy($db->db_connect_id);
+ pg_put_line($db->get_db_connect_id(), "\\.\n");
+ pg_end_copy($db->get_db_connect_id());
}
}
break;
@@ -623,7 +623,7 @@ function write_table($table_name)
if ($new_extract === null)
{
- if ($db->sql_layer === 'mysqli' || version_compare($db->sql_server_info(true), '3.23.20', '>='))
+ if ($db->get_sql_layer() === 'mysqli' || version_compare($db->sql_server_info(true), '3.23.20', '>='))
{
$new_extract = true;
}
@@ -646,7 +646,7 @@ function write_table($table_name)
function write_data($table_name)
{
global $db;
- if ($db->sql_layer === 'mysqli')
+ if ($db->get_sql_layer() === 'mysqli')
{
$this->write_data_mysqli($table_name);
}
@@ -661,7 +661,7 @@ function write_data_mysqli($table_name)
global $db;
$sql = "SELECT *
FROM $table_name";
- $result = mysqli_query($db->db_connect_id, $sql, MYSQLI_USE_RESULT);
+ $result = mysqli_query($db->get_db_connect_id(), $sql, MYSQLI_USE_RESULT);
if ($result != false)
{
$fields_cnt = mysqli_num_fields($result);
@@ -740,7 +740,7 @@ function write_data_mysql($table_name)
global $db;
$sql = "SELECT *
FROM $table_name";
- $result = mysql_unbuffered_query($sql, $db->db_connect_id);
+ $result = mysql_unbuffered_query($sql, $db->get_db_connect_id());
if ($result != false)
{
@@ -993,11 +993,11 @@ function write_data($table_name)
{
global $db;
- $col_types = sqlite_fetch_column_types($db->db_connect_id, $table_name);
+ $col_types = sqlite_fetch_column_types($db->get_db_connect_id(), $table_name);
$sql = "SELECT *
FROM $table_name";
- $result = sqlite_unbuffered_query($db->db_connect_id, $sql);
+ $result = sqlite_unbuffered_query($db->get_db_connect_id(), $sql);
$rows = sqlite_fetch_all($result, SQLITE_ASSOC);
$sql_insert = 'INSERT INTO ' . $table_name . ' (' . implode(', ', array_keys($col_types)) . ') VALUES (';
foreach ($rows as $row)
@@ -1553,11 +1553,11 @@ function write_data($table_name)
{
global $db;
- if ($db->sql_layer === 'mssql')
+ if ($db->get_sql_layer() === 'mssql')
{
$this->write_data_mssql($table_name);
}
- else if($db->sql_layer === 'mssqlnative')
+ else if($db->get_sql_layer() === 'mssqlnative')
{
$this->write_data_mssqlnative($table_name);
}
@@ -1827,7 +1827,7 @@ function delete_forum_content($forum_id)
}
$db->sql_freeresult($result);
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mysql4':
case 'mysqli':
@@ -538,7 +538,7 @@ function main($id, $mode)
// The user has already selected a smilies_pak file
if ($current == 'delete')
{
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
@@ -269,7 +269,7 @@ function main($id, $mode)
break;
case 'db_track':
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
@@ -374,7 +374,7 @@ function main($id, $mode)
foreach ($tables as $table)
{
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
@@ -253,7 +253,7 @@ function main($id, $mode)
{
$sql = 'SELECT auth_option_id, auth_option
FROM ' . ACL_OPTIONS_TABLE . "
- WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char) . "
+ WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char()) . "
AND auth_option <> '{$permission_type}'
ORDER BY auth_option_id";
$result = $db->sql_query($sql);
@@ -315,7 +315,7 @@ function main($id, $mode)
// We need to fill the auth options array with ACL_NO options ;)
$sql = 'SELECT auth_option_id, auth_option
FROM ' . ACL_OPTIONS_TABLE . "
- WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char) . "
+ WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char()) . "
AND auth_option <> '{$permission_type}'
ORDER BY auth_option_id";
$result = $db->sql_query($sql);
@@ -519,7 +519,7 @@ function remove_role($role_id, $permission_type)
// Get complete auth array
$sql = 'SELECT auth_option, auth_option_id
FROM ' . ACL_OPTIONS_TABLE . "
- WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char);
+ WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char());
$result = $db->sql_query($sql);
$auth_settings = array();
@@ -1238,7 +1238,7 @@ function retrieve_defined_user_groups($permission_scope, $forum_id, $permission_
$sql = 'SELECT auth_option_id
FROM ' . ACL_OPTIONS_TABLE . '
- WHERE auth_option ' . $db->sql_like_expression($permission_type . $db->any_char);
+ WHERE auth_option ' . $db->sql_like_expression($permission_type . $db->get_any_char());
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -112,7 +112,7 @@ function main($id, $mode)
$db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id");
$db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id");
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
@@ -1196,7 +1196,7 @@ function add_field_ident($field_ident, $sql_type)
{
global $db;
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mysql':
case 'mysql4':
@@ -436,8 +436,8 @@ function get_prune_users(&$user_ids, &$usernames)
$sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit');
$where_sql = '';
- $where_sql .= ($username) ? ' AND username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($username))) : '';
- $where_sql .= ($email) ? ' AND user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : '';
+ $where_sql .= ($username) ? ' AND username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : '';
+ $where_sql .= ($email) ? ' AND user_email ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $email)) . ' ' : '';
$where_sql .= $joined_sql;
$where_sql .= ($count) ? " AND user_posts " . $key_match[$count_select] . ' ' . (int) $count . ' ' : '';
@@ -219,7 +219,7 @@ function main($id, $mode)
$other_reason_id = (int) $db->sql_fetchfield('reason_id');
$db->sql_freeresult($result);
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
// The ugly one!
case 'mysqli':
@@ -2384,7 +2384,7 @@ function main($id, $mode)
// Select auth options
$sql = 'SELECT auth_option, is_local, is_global
FROM ' . ACL_OPTIONS_TABLE . '
- WHERE auth_option ' . $db->sql_like_expression($db->any_char . '_') . '
+ WHERE auth_option ' . $db->sql_like_expression($db->get_any_char() . '_') . '
AND is_global = 1
ORDER BY auth_option';
$result = $db->sql_query($sql);
@@ -2404,7 +2404,7 @@ function main($id, $mode)
{
$sql = 'SELECT auth_option, is_local, is_global
FROM ' . ACL_OPTIONS_TABLE . "
- WHERE auth_option " . $db->sql_like_expression($db->any_char . '_') . "
+ WHERE auth_option " . $db->sql_like_expression($db->get_any_char() . '_') . "
AND is_local = 1
ORDER BY is_global DESC, auth_option";
$result = $db->sql_query($sql);
@@ -1024,7 +1024,7 @@ function acl_delete($mode, $ug_id = false, $forum_id = false, $permission_type =
// Get permission type
$sql = 'SELECT auth_option, auth_option_id
FROM ' . ACL_OPTIONS_TABLE . "
- WHERE auth_option " . $db->sql_like_expression($permission_type . $db->any_char);
+ WHERE auth_option " . $db->sql_like_expression($permission_type . $db->get_any_char());
$result = $db->sql_query($sql);
$auth_id_ary = array();
@@ -4029,7 +4029,7 @@ function obtain_guest_count($item_id = 0, $item = 'forum')
// Get number of online guests
- if ($db->sql_layer === 'sqlite' || $db->sql_layer === 'sqlite3')
+ if ($db->get_sql_layer() === 'sqlite' || $db->get_sql_layer() === 'sqlite3')
{
$sql = 'SELECT COUNT(session_ip) as num_guests
FROM (
@@ -5096,7 +5096,7 @@ function phpbb_generate_debug_output(phpbb\db\driver\driver_interface $db, \phpb
if (isset($GLOBALS['starttime']))
{
$totaltime = microtime(true) - $GLOBALS['starttime'];
- $debug_info[] = sprintf('<abbr title="SQL time: %.3fs / PHP time: %.3fs">Time: %.3fs</abbr>', $db->sql_time, ($totaltime - $db->sql_time), $totaltime);
+ $debug_info[] = sprintf('<abbr title="SQL time: %.3fs / PHP time: %.3fs">Time: %.3fs</abbr>', $db->get_sql_time(), ($totaltime - $db->get_sql_time()), $totaltime);
}
$debug_info[] = sprintf('<abbr title="Cached: %d">Queries: %d</abbr>', $db->sql_num_queries(true), $db->sql_num_queries());
@@ -1435,7 +1435,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
{
case 'topic_moved':
$db->sql_transaction('begin');
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mysql4':
case 'mysqli':
@@ -2441,7 +2441,7 @@ function phpbb_cache_moderators($db, $cache, $auth)
$cache->destroy('sql', MODERATOR_CACHE_TABLE);
// Clear table
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
@@ -2491,7 +2491,7 @@ function phpbb_cache_moderators($db, $cache, $auth)
AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1)
AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . "
AND ug.user_pending = 0
- AND o.auth_option " . $db->sql_like_expression('m_' . $db->any_char),
+ AND o.auth_option " . $db->sql_like_expression('m_' . $db->get_any_char()),
);
$sql = $db->sql_build_query('SELECT', $sql_ary_deny);
$result = $db->sql_query($sql);
@@ -2697,11 +2697,11 @@ function phpbb_update_foes($db, $auth, $group_id = false, $user_id = false)
return;
}
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mysqli':
case 'mysql4':
- $sql = 'DELETE ' . (($db->sql_layer === 'mysqli' || version_compare($db->sql_server_info(true), '4.1', '>=')) ? 'z.*' : ZEBRA_TABLE) . '
+ $sql = 'DELETE ' . (($db->get_sql_layer() === 'mysqli' || version_compare($db->sql_server_info(true), '4.1', '>=')) ? 'z.*' : ZEBRA_TABLE) . '
FROM ' . ZEBRA_TABLE . ' z, ' . USER_GROUP_TABLE . ' ug
WHERE z.zebra_id = ug.user_id
AND z.foe = 1
@@ -2854,7 +2854,7 @@ function get_database_size()
$database_size = false;
// This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mysql':
case 'mysql4':
@@ -2870,7 +2870,7 @@ function get_database_size()
if (preg_match('#(3\.23|[45]\.)#', $version))
{
- $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$db->dbname}`" : $db->dbname;
+ $db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name();
$sql = 'SHOW TABLE STATUS
FROM ' . $db_name;
@@ -2946,7 +2946,7 @@ function get_database_size()
if ($row['proname'] == 'pg_database_size')
{
- $database = $db->dbname;
+ $database = $db->get_db_name();
if (strpos($database, '.') !== false)
{
list($database, ) = explode('.', $database);
Oops, something went wrong.

0 comments on commit 53ff236

Please sign in to comment.