Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'develop-ascraeus' into develop

* develop-ascraeus:
  [ticket/12446] Unnecessary db connect inphpbb_bootstrap_enabled_exts
  • Loading branch information...
commit e97fab49e2ce73a8cc179a934ed8c0a05057bda3 2 parents 4558262 + 53ff236
@naderman naderman authored
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
View
5 phpBB/config/services.yml
@@ -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%]]
View
2  phpBB/develop/add_permissions.php
@@ -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':
View
2  phpBB/develop/benchmark.php
@@ -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";
View
2  phpBB/develop/merge_attachment_tables.php
@@ -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':
View
4 phpBB/develop/merge_post_tables.php
@@ -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
View
5 phpBB/download/file.php
@@ -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);
View
28 phpBB/includes/acp/acp_database.php
@@ -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);
}
View
2  phpBB/includes/acp/acp_forums.php
@@ -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':
View
2  phpBB/includes/acp/acp_icons.php
@@ -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':
View
4 phpBB/includes/acp/acp_main.php
@@ -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':
View
6 phpBB/includes/acp/acp_permission_roles.php
@@ -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();
View
2  phpBB/includes/acp/acp_permissions.php
@@ -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))
View
4 phpBB/includes/acp/acp_profile.php
@@ -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':
View
4 phpBB/includes/acp/acp_prune.php
@@ -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 . ' ' : '';
View
2  phpBB/includes/acp/acp_reasons.php
@@ -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':
View
4 phpBB/includes/acp/acp_users.php
@@ -2379,7 +2379,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);
@@ -2399,7 +2399,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);
View
2  phpBB/includes/acp/auth.php
@@ -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();
View
4 phpBB/includes/functions.php
@@ -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());
View
16 phpBB/includes/functions_admin.php
@@ -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);
View
14 phpBB/includes/functions_container.php
@@ -64,9 +64,10 @@ function phpbb_bootstrap_table_prefix($config_file)
*
* @param string $config_file
* @param string $phpbb_root_path
+* @param \phpbb\db\driver\driver_interface $db The generated connection
* @return array enabled extensions
*/
-function phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path)
+function phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path, &$db)
{
$db = phpbb_bootstrap_db_connection($config_file);
$table_prefix = phpbb_bootstrap_table_prefix($config_file);
@@ -133,7 +134,7 @@ function phpbb_create_install_container($phpbb_root_path, $php_ext)
$container->setParameter('core.php_ext', $php_ext);
$container->setParameter('core.table_prefix', '');
- $container->register('dbal.conn')->setSynthetic(true);
+ $container->register('dbal.conn.driver')->setSynthetic(true);
$container->setAlias('cache.driver', 'cache.driver.install');
@@ -259,9 +260,10 @@ function phpbb_create_dumped_container_unless_debug($config_file, array $extensi
function phpbb_create_default_container($phpbb_root_path, $php_ext)
{
$config_file = $phpbb_root_path . 'config.' . $php_ext;
- $installed_exts = phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path);
+ $db = null;
+ $installed_exts = phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path, $db);
- return phpbb_create_dumped_container_unless_debug(
+ $container = phpbb_create_dumped_container_unless_debug(
$config_file,
array(
new \phpbb\di\extension\config($config_file),
@@ -275,6 +277,10 @@ function phpbb_create_default_container($phpbb_root_path, $php_ext)
$phpbb_root_path,
$php_ext
);
+
+ $container->get('dbal.conn')->set_driver($db);
+
+ return $container;
}
/**
View
4 phpBB/includes/functions_convert.php
@@ -1647,7 +1647,7 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting = ACL_NO)
switch ($sql_type)
{
case 'insert':
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mysql':
case 'mysql4':
@@ -2041,7 +2041,7 @@ function update_topics_posted()
{
global $db, $config;
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
View
2  phpBB/includes/functions_install.php
@@ -290,7 +290,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
switch ($dbms_details['DRIVER'])
{
case 'phpbb\db\driver\mysqli':
- if (version_compare(mysqli_get_server_info($db->db_connect_id), '4.1.3', '<'))
+ if (version_compare(mysqli_get_server_info($db->get_db_connect_id()), '4.1.3', '<'))
{
$error[] = $lang['INST_ERR_DB_NO_MYSQLI'];
}
View
2  phpBB/includes/message_parser.php
@@ -1350,7 +1350,7 @@ function smilies($max_smilies = 0)
// NOTE: obtain_* function? chaching the table contents?
// For now setting the ttl to 10 minutes
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mssql':
case 'mssql_odbc':
View
8 phpBB/install/convertors/functions_phpbb20.php
@@ -92,7 +92,7 @@ function phpbb_insert_forums()
$src_db->sql_query("SET NAMES 'utf8'");
}
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mssql':
case 'mssql_odbc':
@@ -289,7 +289,7 @@ function phpbb_insert_forums()
}
$src_db->sql_freeresult($result);
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'postgres':
$db->sql_query("SELECT SETVAL('" . FORUMS_TABLE . "_seq',(select case when max(forum_id)>0 then max(forum_id)+1 else 1 end from " . FORUMS_TABLE . '));');
@@ -1768,7 +1768,7 @@ function phpbb_create_userconv_table()
global $db, $src_db, $convert, $table_prefix, $user, $lang;
$map_dbms = '';
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mysql':
$map_dbms = 'mysql_40';
@@ -1796,7 +1796,7 @@ function phpbb_create_userconv_table()
break;
default:
- $map_dbms = $db->sql_layer;
+ $map_dbms = $db->get_sql_layer();
break;
}
View
2  phpBB/install/database_update.php
@@ -176,7 +176,7 @@ function phpbb_end_update($cache, $config)
<br />
- <p><?php echo $user->lang['DATABASE_TYPE']; ?> :: <strong><?php echo $db->sql_layer; ?></strong><br />
+ <p><?php echo $user->lang['DATABASE_TYPE']; ?> :: <strong><?php echo $db->get_sql_layer(); ?></strong><br />
<?php echo $user->lang['PREVIOUS_VERSION']; ?> :: <strong><?php echo $config['version']; ?></strong><br />
<?php
View
2  phpBB/install/index.php
@@ -688,7 +688,7 @@ function db_error($error, $sql, $line, $file, $skip = false)
));
// Rollback if in transaction
- if ($db->transaction)
+ if ($db->get_transaction())
{
$db->sql_transaction('rollback');
}
View
16 phpBB/install/install_convert.php
@@ -248,7 +248,7 @@ function main($mode, $sub)
));
}
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
@@ -727,7 +727,7 @@ function convert_data($sub)
$src_db->sql_query("SET NAMES 'binary'");
}
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
@@ -1129,7 +1129,7 @@ function convert_data($sub)
if (!empty($schema['autoincrement']))
{
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'postgres':
$db->sql_query("SELECT SETVAL('" . $schema['target'] . "_seq',(select case when max(" . $schema['autoincrement'] . ")>0 then max(" . $schema['autoincrement'] . ")+1 else 1 end from " . $schema['target'] . '));');
@@ -1268,7 +1268,7 @@ function convert_data($sub)
if (!empty($schema['autoincrement']))
{
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mssql':
case 'mssql_odbc':
@@ -1301,7 +1301,7 @@ function convert_data($sub)
if ($sql_flag === true)
{
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
// If MySQL, we'll wait to have num_wait_rows rows to submit at once
case 'mysql':
@@ -1396,7 +1396,7 @@ function convert_data($sub)
if (!empty($schema['autoincrement']))
{
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'mssql':
case 'mssql_odbc':
@@ -1635,7 +1635,7 @@ function final_jump($final_jump)
'RESULT' => $user->lang['DONE'],
));
- if ($db->sql_error_triggered)
+ if ($db->get_sql_error_triggered())
{
$template->assign_vars(array(
'S_ERROR_BOX' => true,
@@ -1808,7 +1808,7 @@ function build_insert_query(&$schema, &$sql_data, $current_table)
global $convert;
// Can we use IGNORE with this DBMS?
- $sql_ignore = (strpos($db->sql_layer, 'mysql') === 0 && !defined('DEBUG')) ? 'IGNORE ' : '';
+ $sql_ignore = (strpos($db->get_sql_layer(), 'mysql') === 0 && !defined('DEBUG')) ? 'IGNORE ' : '';
$insert_query = 'INSERT ' . $sql_ignore . 'INTO ' . $schema['target'] . ' (';
$aliases = array();
View
32 phpBB/install/install_install.php
@@ -1532,10 +1532,10 @@ function add_modules($mode, $sub)
$_module->update_module_data($module_data, true);
// Check for last sql error happened
- if ($db->sql_error_triggered)
+ if ($db->get_sql_error_triggered())
{
- $error = $db->sql_error($db->sql_error_sql);
- $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
+ $error = $db->sql_error($db->get_sql_error_sql());
+ $this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);
}
$categories[$cat_name]['id'] = (int) $module_data['module_id'];
@@ -1566,10 +1566,10 @@ function add_modules($mode, $sub)
$_module->update_module_data($module_data, true);
// Check for last sql error happened
- if ($db->sql_error_triggered)
+ if ($db->get_sql_error_triggered())
{
- $error = $db->sql_error($db->sql_error_sql);
- $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
+ $error = $db->sql_error($db->get_sql_error_sql());
+ $this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);
}
$categories[$level2_name]['id'] = (int) $module_data['module_id'];
@@ -1606,10 +1606,10 @@ function add_modules($mode, $sub)
$_module->update_module_data($module_data, true);
// Check for last sql error happened
- if ($db->sql_error_triggered)
+ if ($db->get_sql_error_triggered())
{
- $error = $db->sql_error($db->sql_error_sql);
- $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
+ $error = $db->sql_error($db->get_sql_error_sql());
+ $this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);
}
}
}
@@ -1772,10 +1772,10 @@ function add_modules($mode, $sub)
$_module->update_module_data($module_data, true);
// Check for last sql error happened
- if ($db->sql_error_triggered)
+ if ($db->get_sql_error_triggered())
{
- $error = $db->sql_error($db->sql_error_sql);
- $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
+ $error = $db->sql_error($db->get_sql_error_sql());
+ $this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);
}
}
}
@@ -1824,10 +1824,10 @@ function add_language($mode, $sub)
$db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $lang_pack));
$installed_languages[] = (int) $db->sql_nextid();
- if ($db->sql_error_triggered)
+ if ($db->get_sql_error_triggered())
{
- $error = $db->sql_error($db->sql_error_sql);
- $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
+ $error = $db->sql_error($db->get_sql_error_sql());
+ $this->p_master->db_error($error['message'], $db->get_sql_error_sql(), __LINE__, __FILE__);
}
}
}
@@ -1913,7 +1913,7 @@ function add_bots($mode, $sub)
if (!$user_id)
{
// If we can't insert this user then continue to the next one to avoid inconsistent data
- $this->p_master->db_error('Unable to insert bot into users table', $db->sql_error_sql, __LINE__, __FILE__, true);
+ $this->p_master->db_error('Unable to insert bot into users table', $db->get_sql_error_sql(), __LINE__, __FILE__, true);
continue;
}
View
12 phpBB/memberlist.php
@@ -799,7 +799,7 @@
$sql = 'SELECT username, user_id, user_colour
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . '
- AND username_clean ' . $db->sql_like_expression(utf8_clean_string($username_chars) . $db->any_char);
+ AND username_clean ' . $db->sql_like_expression(utf8_clean_string($username_chars) . $db->get_any_char());
$result = $db->sql_query_limit($sql, 10);
$user_list = array();
@@ -920,9 +920,9 @@
$s_find_active_time .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
}
- $sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($username))) : '';
- $sql_where .= ($auth->acl_get('a_user') && $email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->any_char, $email)) . ' ' : '';
- $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->any_char, $jabber)) . ' ' : '';
+ $sql_where .= ($username) ? ' AND u.username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($username))) : '';
+ $sql_where .= ($auth->acl_get('a_user') && $email) ? ' AND u.user_email ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $email)) . ' ' : '';
+ $sql_where .= ($jabber) ? ' AND u.user_jabber ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), $jabber)) . ' ' : '';
$sql_where .= (is_numeric($count) && isset($find_key_match[$count_select])) ? ' AND u.user_posts ' . $find_key_match[$count_select] . ' ' . (int) $count . ' ' : '';
if (isset($find_key_match[$joined_select]) && sizeof($joined) == 3)
@@ -1016,12 +1016,12 @@
{
for ($i = 97; $i < 123; $i++)
{
- $sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->any_char);
+ $sql_where .= ' AND u.username_clean NOT ' . $db->sql_like_expression(chr($i) . $db->get_any_char());
}
}
else if ($first_char)
{
- $sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->any_char);
+ $sql_where .= ' AND u.username_clean ' . $db->sql_like_expression(substr($first_char, 0, 1) . $db->get_any_char());
}
// Are we looking at a usergroup? If so, fetch additional info
View
4 phpBB/phpbb/auth/auth.php
@@ -1043,7 +1043,7 @@ function build_auth_option_statement($key, $auth_options, &$sql_opts)
{
if (strpos($auth_options, '%') !== false)
{
- $sql_opts = "AND $key " . $db->sql_like_expression(str_replace('%', $db->any_char, $auth_options));
+ $sql_opts = "AND $key " . $db->sql_like_expression(str_replace('%', $db->get_any_char(), $auth_options));
}
else
{
@@ -1074,7 +1074,7 @@ function build_auth_option_statement($key, $auth_options, &$sql_opts)
{
if (strpos($option, '%') !== false)
{
- $sql[] = $key . ' ' . $db->sql_like_expression(str_replace('%', $db->any_char, $option));
+ $sql[] = $key . ' ' . $db->sql_like_expression(str_replace('%', $db->get_any_char(), $option));
}
else
{
View
2  phpBB/phpbb/cache/service.php
@@ -305,7 +305,7 @@ function obtain_bots()
{
if (($bots = $this->driver->get('_bots')) === false)
{
- switch ($this->db->sql_layer)
+ switch ($this->db->get_sql_layer())
{
case 'mssql':
case 'mssql_odbc':
View
96 phpBB/phpbb/db/driver/driver.php
@@ -87,6 +87,102 @@ function __construct()
}
/**
+ * {@inheritdoc}
+ */
+ public function get_sql_layer()
+ {
+ return $this->sql_layer;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_db_name()
+ {
+ return $this->dbname;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_any_char()
+ {
+ return $this->any_char;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_one_char()
+ {
+ return $this->one_char;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_db_connect_id()
+ {
+ return $this->db_connect_id;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_sql_error_triggered()
+ {
+ return $this->sql_error_triggered;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_sql_error_sql()
+ {
+ return $this->sql_error_sql;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_transaction()
+ {
+ return $this->transaction;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_sql_time()
+ {
+ return $this->sql_time;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_sql_error_returned()
+ {
+ return $this->sql_error_returned;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_multi_insert()
+ {
+ return $this->multi_insert;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function set_multi_insert($multi_insert)
+ {
+ $this->multi_insert = $multi_insert;
+ }
+
+ /**
* {@inheritDoc}
*/
function sql_return_on_error($fail = false)
View
84 phpBB/phpbb/db/driver/driver_interface.php
@@ -16,6 +16,90 @@
interface driver_interface
{
/**
+ * Gets the name of the sql layer.
+ *
+ * @return string
+ */
+ public function get_sql_layer();
+
+ /**
+ * Gets the name of the database.
+ *
+ * @return string
+ */
+ public function get_db_name();
+
+ /**
+ * Wildcards for matching any (%) character within LIKE expressions
+ *
+ * @return string
+ */
+ public function get_any_char();
+
+ /**
+ * Wildcards for matching exactly one (_) character within LIKE expressions
+ *
+ * @return string
+ */
+ public function get_one_char();
+
+ /**
+ * Gets the time spent into the queries
+ *
+ * @return int
+ */
+ public function get_sql_time();
+
+ /**
+ * Gets the connect ID.
+ *
+ * @return mixed
+ */
+ public function get_db_connect_id();
+
+ /**
+ * Indicates if an error was triggered.
+ *
+ * @return bool
+ */
+ public function get_sql_error_triggered();
+
+ /**
+ * Gets the last faulty query
+ *
+ * @return string
+ */
+ public function get_sql_error_sql();
+
+ /**
+ * Indicates if we are in a transaction.
+ *
+ * @return bool
+ */
+ public function get_transaction();
+
+ /**
+ * Gets the returned error.
+ *
+ * @return array
+ */
+ public function get_sql_error_returned();
+
+ /**
+ * Indicates if multiple insertion can be used
+ *
+ * @return bool
+ */
+ public function get_multi_insert();
+
+ /**
+ * Set if multiple insertion can be used
+ *
+ * @param bool $multi_insert
+ */
+ public function set_multi_insert($multi_insert);
+
+ /**
* Gets the exact number of rows in a specified table.
*
* @param string $table_name Table name
View
435 phpBB/phpbb/db/driver/factory.php
@@ -0,0 +1,435 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+namespace phpbb\db\driver;
+
+use \Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+* Database Abstraction Layer
+*/
+class factory implements driver_interface
+{
+ /**
+ * @var driver_interface
+ */
+ protected $driver = null;
+
+ /**
+ * @var ContainerInterface
+ */
+ protected $container;
+
+ /**
+ * Constructor.
+ *
+ * @param ContainerInterface $container A ContainerInterface instance
+ */
+ public function __construct(ContainerInterface $container)
+ {
+ $this->container = $container;
+ }
+
+ /**
+ * Return the current driver (and retrieved it from the container if necessary)
+ *
+ * @return driver_interface
+ */
+ protected function get_driver()
+ {
+ if ($this->driver === null)
+ {
+ $this->driver = $this->container->get('dbal.conn.driver');
+ }
+
+ return $this->driver;
+ }
+
+ /**
+ * Set the current driver
+ *
+ * @param driver_interface $driver
+ */
+ public function set_driver(driver_interface $driver)
+ {
+ $this->driver = $driver;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_sql_layer()
+ {
+ return $this->get_driver()->get_sql_layer();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_db_name()
+ {
+ return $this->get_driver()->get_db_name();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_any_char()
+ {
+ return $this->get_driver()->get_any_char();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_one_char()
+ {
+ return $this->get_driver()->get_one_char();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_db_connect_id()
+ {
+ return $this->get_driver()->get_db_connect_id();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_sql_error_triggered()
+ {
+ return $this->get_driver()->get_sql_error_triggered();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_sql_error_sql()
+ {
+ return $this->get_driver()->get_sql_error_sql();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_transaction()
+ {
+ return $this->get_driver()->get_transaction();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_sql_time()
+ {
+ return $this->get_driver()->get_sql_time();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_sql_error_returned()
+ {
+ return $this->get_driver()->get_sql_error_returned();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_multi_insert()
+ {
+ return $this->get_driver()->get_multi_insert();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function set_multi_insert($multi_insert)
+ {
+ $this->get_driver()->set_multi_insert($multi_insert);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_row_count($table_name)
+ {
+ return $this->get_driver()->get_row_count($table_name);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function get_estimated_row_count($table_name)
+ {
+ return $this->get_driver()->get_estimated_row_count($table_name);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_lower_text($column_name)
+ {
+ return $this->get_driver()->sql_lower_text($column_name);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_error($sql = '')
+ {
+ return $this->get_driver()->sql_error($sql);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_buffer_nested_transactions()
+ {
+ return $this->get_driver()->sql_buffer_nested_transactions();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_bit_or($column_name, $bit, $compare = '')
+ {
+ return $this->get_driver()->sql_bit_or($column_name, $bit, $compare);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_server_info($raw = false, $use_cache = true)
+ {
+ return $this->get_driver()->sql_server_info($raw, $use_cache);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_return_on_error($fail = false)
+ {
+ return $this->get_driver()->sql_return_on_error($fail);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_build_array($query, $assoc_ary = array())
+ {
+ return $this->get_driver()->sql_build_array($query, $assoc_ary);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_fetchrowset($query_id = false)
+ {
+ return $this->get_driver()->sql_fetchrowset($query_id);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_transaction($status = 'begin')
+ {
+ return $this->get_driver()->sql_transaction($status);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_concatenate($expr1, $expr2)
+ {
+ return $this->get_driver()->sql_concatenate($expr1, $expr2);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_case($condition, $action_true, $action_false = false)
+ {
+ return $this->get_driver()->sql_case($condition, $action_true, $action_false);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_build_query($query, $array)
+ {
+ return $this->get_driver()->sql_build_query($query, $array);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_fetchfield($field, $rownum = false, $query_id = false)
+ {
+ return $this->get_driver()->sql_fetchfield($field, $rownum, $query_id);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_fetchrow($query_id = false)
+ {
+ return $this->get_driver()->sql_fetchrow($query_id);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function cast_expr_to_bigint($expression)
+ {
+ return $this->get_driver()->cast_expr_to_bigint($expression);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_nextid()
+ {
+ return $this->get_driver()->sql_nextid();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_add_num_queries($cached = false)
+ {
+ return $this->get_driver()->sql_add_num_queries($cached);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
+ {
+ return $this->get_driver()->sql_query_limit($query, $total, $offset, $cache_ttl);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_query($query = '', $cache_ttl = 0)
+ {
+ return $this->get_driver()->sql_query($query, $cache_ttl);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function cast_expr_to_string($expression)
+ {
+ return $this->get_driver()->cast_expr_to_string($expression);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
+ {
+ throw new \Exception('Disabled method.');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_bit_and($column_name, $bit, $compare = '')
+ {
+ return $this->get_driver()->sql_bit_and($column_name, $bit, $compare);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_freeresult($query_id = false)
+ {
+ return $this->get_driver()->sql_freeresult($query_id);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_num_queries($cached = false)
+ {
+ return $this->get_driver()->sql_num_queries($cached);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_multi_insert($table, $sql_ary)
+ {
+ return $this->get_driver()->sql_multi_insert($table, $sql_ary);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_affectedrows()
+ {
+ return $this->get_driver()->sql_affectedrows();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_close()
+ {
+ return $this->get_driver()->sql_close();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_rowseek($rownum, &$query_id)
+ {
+ return $this->get_driver()->sql_rowseek($rownum, $query_id);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_escape($msg)
+ {
+ return $this->get_driver()->sql_escape($msg);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_like_expression($expression)
+ {
+ return $this->get_driver()->sql_like_expression($expression);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_report($mode, $query = '')
+ {
+ return $this->get_driver()->sql_report($mode, $query);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function sql_in_set($field, $array, $negate = false, $allow_empty_set = false)
+ {
+ return $this->get_driver()->sql_in_set($field, $array, $negate, $allow_empty_set);
+ }
+}
View
2  phpBB/phpbb/db/migration/data/v30x/local_url_bbcode.php
@@ -37,7 +37,7 @@ public function update_local_url_bbcode()
{
$sql = 'SELECT *
FROM ' . BBCODES_TABLE . '
- WHERE bbcode_match ' . $this->db->sql_like_expression($this->db->any_char . 'LOCAL_URL' . $this->db->any_char);
+ WHERE bbcode_match ' . $this->db->sql_like_expression($this->db->get_any_char() . 'LOCAL_URL' . $this->db->get_any_char());
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
View
2  phpBB/phpbb/db/migration/data/v30x/release_3_0_4.php
@@ -36,7 +36,7 @@ public function update_data()
public function rename_log_delete_topic()
{
- if ($this->db->sql_layer == 'oracle')
+ if ($this->db->get_sql_layer() == 'oracle')
{
// log_operation is CLOB - but we can change this later
$sql = 'UPDATE ' . $this->table_prefix . "log
View
2  phpBB/phpbb/db/migration/data/v30x/release_3_0_7_rc1.php
@@ -76,7 +76,7 @@ public function delete_text_templates()
{
// Delete all text-templates from the template_data
$sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . '
- WHERE template_filename ' . $this->db->sql_like_expression($this->db->any_char . '.txt');
+ WHERE template_filename ' . $this->db->sql_like_expression($this->db->get_any_char() . '.txt');
$this->sql_query($sql);
}
}
View
2  phpBB/phpbb/db/migration/data/v30x/release_3_0_9_rc1.php
@@ -89,7 +89,7 @@ public function update_file_extension_group_names()
// Update file extension group names to use language strings, again.
$sql = 'SELECT group_id, group_name
FROM ' . EXTENSION_GROUPS_TABLE . '
- WHERE group_name ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->any_char);
+ WHERE group_name ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->get_any_char());
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
View
2  phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php
@@ -18,7 +18,7 @@ class mysql_fulltext_drop extends \phpbb\db\migration\migration
public function effectively_installed()
{
// This migration is irrelevant for all non-MySQL DBMSes.
- return strpos($this->db->sql_layer, 'mysql') === false;
+ return strpos($this->db->get_sql_layer(), 'mysql') === false;
}
static public function depends_on()
View
2  phpBB/phpbb/db/migration/data/v310/postgres_fulltext_drop.php
@@ -18,7 +18,7 @@ class postgres_fulltext_drop extends \phpbb\db\migration\migration
public function effectively_installed()
{
// This migration is irrelevant for all non-PostgreSQL DBMSes.
- return strpos($this->db->sql_layer, 'postgres') === false;
+ return strpos($this->db->get_sql_layer(), 'postgres') === false;
}
static public function depends_on()
View
6 phpBB/phpbb/db/migration/migration.php
@@ -160,11 +160,11 @@ protected function sql_query($sql)
else
{
$result = $this->db->sql_query($sql);
- if ($this->db->sql_error_triggered)
+ if ($this->db->get_sql_error_triggered())
{
$this->errors[] = array(
- 'sql' => $this->db->sql_error_sql,
- 'code' => $this->db->sql_error_returned,
+ 'sql' => $this->db->get_sql_error_sql(),
+ 'code' => $this->db->get_sql_error_returned(),
);
}
}
View
2  phpBB/phpbb/db/migrator.php
@@ -110,7 +110,7 @@ public function load_migration_state()
FROM " . $this->migrations_table;
$result = $this->db->sql_query($sql);
- if (!$this->db->sql_error_triggered)
+ if (!$this->db->get_sql_error_triggered())
{
while ($migration = $this->db->sql_fetchrow($result))
{
View
2  phpBB/phpbb/db/sql_insert_buffer.php
@@ -92,7 +92,7 @@ public function insert(array $row)
// Flush buffer if it is full or when DB does not support multi inserts.
// In the later case, the buffer will always only contain one row.
- if (!$this->db->multi_insert || sizeof($this->buffer) >= $this->max_buffered_rows)
+ if (!$this->db->get_multi_insert() || sizeof($this->buffer) >= $this->max_buffered_rows)
{
return $this->flush();
}
View
8 phpBB/phpbb/db/tools.php
@@ -323,7 +323,7 @@ public function __construct(\phpbb\db\driver\driver_interface $db, $return_state
$this->dbms_type_map = self::get_dbms_type_map();
// Determine mapping database type
- switch ($this->db->sql_layer)
+ switch ($this->db->get_sql_layer())
{
case 'mysql':
$this->sql_layer = 'mysql_40';
@@ -354,7 +354,7 @@ public function __construct(\phpbb\db\driver\driver_interface $db, $return_state
break;
default:
- $this->sql_layer = $this->db->sql_layer;
+ $this->sql_layer = $this->db->get_sql_layer();
break;
}
}
@@ -377,7 +377,7 @@ public function set_return_statements($return_statements)
*/
function sql_list_tables()
{
- switch ($this->db->sql_layer)
+ switch ($this->db->get_sql_layer())
{
case 'mysql':
case 'mysql4':
@@ -711,7 +711,7 @@ function perform_schema_changes($schema_changes)
$sqlite = false;
// For SQLite we need to perform the schema changes in a much more different way
- if (($this->db->sql_layer == 'sqlite' || $this->db->sql_layer == 'sqlite3') && $this->return_statements)
+ if (($this->db->get_sql_layer() == 'sqlite' || $this->db->get_sql_layer() == 'sqlite3') && $this->return_statements)
{
$sqlite_data = array();
$sqlite = true;
View
2  phpBB/phpbb/log/log.php
@@ -737,7 +737,7 @@ protected function generate_sql_keyword($keywords, $table_alias = 'l.', $stateme
for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++)
{
$keywords_pattern[] = preg_quote($keywords[$i], '#');
- $keywords[$i] = $this->db->sql_like_expression($this->db->any_char . $keywords[$i] . $this->db->any_char);
+ $keywords[$i] = $this->db->sql_like_expression($this->db->get_any_char() . $keywords[$i] . $this->db->get_any_char());
}
$keywords_pattern = '#' . implode('|', $keywords_pattern) . '#ui';
View
4 phpBB/phpbb/search/base.php
@@ -282,7 +282,7 @@ function destroy_cache($words, $authors = false)
$sql_where = '';
foreach ($words as $word)
{
- $sql_where .= " OR search_keywords " . $db->sql_like_expression($db->any_char . $word . $db->any_char);
+ $sql_where .= " OR search_keywords " . $db->sql_like_expression($db->get_any_char() . $word . $db->get_any_char());
}
$sql = 'SELECT search_key
@@ -303,7 +303,7 @@ function destroy_cache($words, $authors = false)
$sql_where = '';
foreach ($authors as $author)
{
- $sql_where .= (($sql_where) ? ' OR ' : '') . 'search_authors ' . $db->sql_like_expression($db->any_char . ' ' . (int) $author . ' ' . $db->any_char);
+ $sql_where .= (($sql_where) ? ' OR ' : '') . 'search_authors ' . $db->sql_like_expression($db->get_any_char() . ' ' . (int) $author . ' ' . $db->get_any_char());
}
$sql = 'SELECT search_key
View
8 phpBB/phpbb/search/fulltext_mysql.php
@@ -140,7 +140,7 @@ public function get_word_length()
*/
public function init()
{
- if ($this->db->sql_layer != 'mysql4' && $this->db->sql_layer != 'mysqli')
+ if ($this->db->get_sql_layer() != 'mysql4' && $this->db->get_sql_layer() != 'mysqli')
{
return $this->user->lang['FULLTEXT_MYSQL_INCOMPATIBLE_DATABASE'];
}
@@ -764,7 +764,7 @@ public function create_index($acp_module, $u_action)
if (!isset($this->stats['post_subject']))
{
- if ($this->db->sql_layer == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
+ if ($this->db->get_sql_layer() == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
{
$alter[] = 'MODIFY post_subject varchar(255) COLLATE utf8_unicode_ci DEFAULT \'\' NOT NULL';
}
@@ -777,7 +777,7 @@ public function create_index($acp_module, $u_action)
if (!isset($this->stats['post_content']))
{
- if ($this->db->sql_layer == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
+ if ($this->db->get_sql_layer() == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
{
$alter[] = 'MODIFY post_text mediumtext COLLATE utf8_unicode_ci NOT NULL';
}
@@ -872,7 +872,7 @@ public function index_stats()
*/
protected function get_stats()
{
- if (strpos($this->db->sql_layer, 'mysql') === false)
+ if (strpos($this->db->get_sql_layer(), 'mysql') === false)
{
$this->stats = array();
return;
View
10 phpBB/phpbb/search/fulltext_native.php
@@ -758,7 +758,7 @@ public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key,
);
}
- switch ($this->db->sql_layer)
+ switch ($this->db->get_sql_layer())
{
case 'mysql4':
case 'mysqli':
@@ -978,7 +978,7 @@ public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $
// If the cache was completely empty count the results
if (!$total_results)
{
- switch ($this->db->sql_layer)
+ switch ($this->db->get_sql_layer())
{
case 'mysql4':
case 'mysqli':
@@ -1000,7 +1000,7 @@ public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $
}
else
{
- if ($this->db->sql_layer == 'sqlite' || $this->db->sql_layer == 'sqlite3')
+ if ($this->db->get_sql_layer() == 'sqlite' || $this->db->get_sql_layer() == 'sqlite3')
{
$sql = 'SELECT COUNT(topic_id) as total_results
FROM (SELECT DISTINCT t.topic_id';
@@ -1017,7 +1017,7 @@ public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $
$post_visibility
$sql_fora
AND t.topic_id = p.topic_id
- $sql_time" . (($this->db->sql_layer == 'sqlite' || $this->db->sql_layer == 'sqlite3') ? ')' : '');
+ $sql_time" . (($this->db->get_sql_layer() == 'sqlite' || $this->db->get_sql_layer() == 'sqlite3') ? ')' : '');
}
$result = $this->db->sql_query($sql);
@@ -1481,7 +1481,7 @@ public function tidy()
*/
public function delete_index($acp_module, $u_action)
{
- switch ($this->db->sql_layer)
+ switch ($this->db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
View
8 phpBB/phpbb/search/fulltext_postgres.php
@@ -107,7 +107,7 @@ public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $
$this->word_length = array('min' => $this->config['fulltext_postgres_min_word_len'], 'max' => $this->config['fulltext_postgres_max_word_len']);
- if ($this->db->sql_layer == 'postgres')
+ if ($this->db->get_sql_layer() == 'postgres')
{
$pgsql_version = explode(',', substr($this->db->sql_server_info(), 10));
$this->version = trim($pgsql_version[0]);
@@ -185,7 +185,7 @@ public function supports_phrase_search()
*/
public function init()
{
- if ($this->db->sql_layer != 'postgres')
+ if ($this->db->get_sql_layer() != 'postgres')
{
return $this->user->lang['FULLTEXT_POSTGRES_INCOMPATIBLE_DATABASE'];
}
@@ -869,7 +869,7 @@ public function index_stats()
*/
protected function get_stats()
{
- if ($this->db->sql_layer != 'postgres')
+ if ($this->db->get_sql_layer() != 'postgres')
{
$this->stats = array();
return;
@@ -919,7 +919,7 @@ public function acp()
<dt><label>' . $this->user->lang['FULLTEXT_POSTGRES_TS_NAME'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_TS_NAME_EXPLAIN'] . '</span></dt>
<dd><select name="config[fulltext_postgres_ts_name]">';
- if ($this->db->sql_layer == 'postgres' && $this->tsearch_usable)
+ if ($this->db->get_sql_layer() == 'postgres' && $this->tsearch_usable)
{
$sql = 'SELECT cfgname AS ts_name
FROM pg_ts_config';
View
6 phpBB/phpbb/search/fulltext_sphinx.php
@@ -199,7 +199,7 @@ public function get_common_words()
*/
public function init()
{
- if ($this->db->sql_layer != 'mysql' && $this->db->sql_layer != 'mysql4' && $this->db->sql_layer != 'mysqli' && $this->db->sql_layer != 'postgres')
+ if ($this->db->get_sql_layer() != 'mysql' && $this->db->get_sql_layer() != 'mysql4' && $this->db->get_sql_layer() != 'mysqli' && $this->db->get_sql_layer() != 'postgres')
{
return $this->user->lang['FULLTEXT_SPHINX_WRONG_DATABASE'];
}
@@ -218,11 +218,11 @@ public function init()
protected function config_generate()
{
// Check if Database is supported by Sphinx
- if ($this->db->sql_layer =='mysql' || $this->db->sql_layer == 'mysql4' || $this->db->sql_layer == 'mysqli')
+ if ($this->db->get_sql_layer() =='mysql' || $this->db->get_sql_layer() == 'mysql4' || $this->db->get_sql_layer() == 'mysqli')
{
$this->dbtype = 'mysql';
}
- else if ($this->db->sql_layer == 'postgres')
+ else if ($this->db->get_sql_layer() == 'postgres')
{
$this->dbtype = 'pgsql';
}
View
8 phpBB/search.php
@@ -145,7 +145,7 @@
trigger_error($user->lang('TOO_FEW_AUTHOR_CHARS', (int) $config['min_search_author_chars']));
}
- $sql_where = (strpos($author, '*') !== false) ? ' username_clean ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " username_clean = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
+ $sql_where = (strpos($author, '*') !== false) ? ' username_clean ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " username_clean = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
$sql = 'SELECT user_id
FROM ' . USERS_TABLE . "
@@ -159,7 +159,7 @@
}
$db->sql_freeresult($result);
- $sql_where = (strpos($author, '*') !== false) ? ' post_username ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " post_username = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
+ $sql_where = (strpos($author, '*') !== false) ? ' post_username ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " post_username = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
$sql = 'SELECT 1 as guest_post
FROM ' . POSTS_TABLE . "
@@ -172,7 +172,7 @@
if ($found_guest_post)
{
$author_id_ary[] = ANONYMOUS;
- $sql_author_match = (strpos($author, '*') !== false) ? ' ' . $db->sql_like_expression(str_replace('*', $db->any_char, utf8_clean_string($author))) : " = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
+ $sql_author_match = (strpos($author, '*') !== false) ? ' ' . $db->sql_like_expression(str_replace('*', $db->get_any_char(), utf8_clean_string($author))) : " = '" . $db->sql_escape(utf8_clean_string($author)) . "'";
}
if (!sizeof($author_id_ary))
@@ -1296,7 +1296,7 @@
if ($auth->acl_get('a_search'))
{
// Handle large objects differently for Oracle and MSSQL
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'oracle':
$sql = 'SELECT search_time, search_keywords
View
2  phpBB/viewonline.php
@@ -103,7 +103,7 @@
// Get number of online guests (if we do not display them)
if (!$show_guests)
{
- switch ($db->sql_layer)
+ switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
View
2  tests/dbal/order_lower_test.php
@@ -22,7 +22,7 @@ public function test_order_lower()
{
$db = $this->new_dbal();
- if (strpos($db->sql_layer, 'mysql') === 0 && version_compare($db->sql_server_info(true, false), '5.6', '>='))
+ if (strpos($db->get_sql_layer(), 'mysql') === 0 && version_compare($db->sql_server_info(true, false), '5.6', '>='))
{
$this->markTestSkipped('MySQL 5.6 fails to order things correctly. See also: http://tracker.phpbb.com/browse/PHPBB3-11571 http://bugs.mysql.com/bug.php?id=69005');
}
View
4 tests/dbal/select_test.php
@@ -219,8 +219,8 @@ public function test_like_expression($like_expression, $expected)
{
$db = $this->new_dbal();
- $like_expression = str_replace('*', $db->any_char, $like_expression);
- $like_expression = str_replace('#', $db->one_char, $like_expression);
+ $like_expression = str_replace('*', $db->get_any_char(), $like_expression);
+ $like_expression = str_replace('#', $db->get_one_char(), $like_expression);
$where = ($like_expression) ? 'username_clean ' . $db->sql_like_expression($like_expression) : '';
$result = $db->sql_query('SELECT username_clean
View
8 tests/dbal/sql_insert_buffer_test.php
@@ -32,7 +32,7 @@ public function getDataSet()
public function test_multi_insert_disabled_insert_and_flush()
{
- $this->db->multi_insert = false;
+ $this->db->set_multi_insert(false);
$this->assertTrue($this->buffer->insert($this->get_row(1)));
$this->assert_config_count(3);
$this->assertFalse($this->buffer->flush());
@@ -50,7 +50,7 @@ public function test_multi_insert_enabled_insert_and_flush()
public function test_multi_insert_disabled_insert_with_flush()
{
- $this->db->multi_insert = false;
+ $this->db->set_multi_insert(false);
$this->assertTrue($this->buffer->insert($this->get_row(1)));
$this->assert_config_count(3);
$this->assertTrue($this->buffer->insert($this->get_row(2)));
@@ -68,7 +68,7 @@ public function test_multi_insert_enabled_insert_with_flush()
public function test_multi_insert_disabled_insert_all_and_flush()
{
- $this->db->multi_insert = false;
+ $this->db->set_multi_insert(false);
$this->assertTrue($this->buffer->insert_all($this->get_rows(3)));
$this->assert_config_count(5);
}
@@ -93,7 +93,7 @@ protected function assert_config_count($num_configs)
protected function check_multi_insert_support()
{
- if (!$this->db->multi_insert)
+ if (!$this->db->get_multi_insert())
{
$this->markTestSkipped('Database does not support multi_insert');
}
Please sign in to comment.
Something went wrong with that request. Please try again.