mirror of
https://github.com/phpbb/phpbb.git
synced 2025-01-17 22:28:46 +01:00
[ticket/10748] Replace direct creations of tools();
PHPBB3-10748
This commit is contained in:
parent
4ea90ca44d
commit
37ae99c75d
@ -49,7 +49,10 @@ $classes = $finder->core_path('phpbb/')
|
||||
->get_classes();
|
||||
|
||||
$db = new \phpbb\db\driver\sqlite();
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($db, true);
|
||||
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$schema_data = $schema_generator->get_schema();
|
||||
|
||||
$fp = fopen($schema_path . 'schema.json', 'wb');
|
||||
|
@ -67,7 +67,10 @@ $classes = $finder->core_path('phpbb/')
|
||||
->directory('/db/migration/data')
|
||||
->get_classes();
|
||||
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, $config, $db, new \phpbb\db\tools\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($db, true);
|
||||
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, $config, $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$schema_data = $schema_generator->get_schema();
|
||||
$dbms_type_map = \phpbb\db\tools\tools::get_dbms_type_map();
|
||||
|
||||
|
@ -26,10 +26,10 @@ class acp_database
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $cache, $db, $user, $auth, $template, $table_prefix, $request;
|
||||
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_log;
|
||||
global $cache, $db, $user, $template, $table_prefix, $request;
|
||||
global $phpbb_root_path, $phpbb_container, $phpbb_log;
|
||||
|
||||
$this->db_tools = new \phpbb\db\tools\tools($db);
|
||||
$this->db_tools = $phpbb_container->get('dbal.tools');
|
||||
|
||||
$user->add_lang('acp/database');
|
||||
|
||||
|
@ -188,7 +188,8 @@ function dbms_select($default = '', $only_20x_options = false)
|
||||
*/
|
||||
function get_tables(&$db)
|
||||
{
|
||||
$db_tools = new \phpbb\db\tools\tools($db);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($db);
|
||||
|
||||
return $db_tools->sql_list_tables();
|
||||
}
|
||||
|
@ -1926,7 +1926,9 @@ function phpbb_check_username_collisions()
|
||||
function phpbb_convert_timezone($timezone)
|
||||
{
|
||||
global $config, $db, $phpbb_root_path, $phpEx, $table_prefix;
|
||||
$timezone_migration = new \phpbb\db\migration\data\v310\timezone($config, $db, new \phpbb\db\tools\tools($db), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$timezone_migration = new \phpbb\db\migration\data\v310\timezone($config, $db, $factory->get($db), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
return $timezone_migration->convert_phpbb30_timezone($timezone, 0);
|
||||
}
|
||||
|
||||
|
@ -1200,7 +1200,9 @@ class install_install extends module
|
||||
->get_classes();
|
||||
|
||||
$sqlite_db = new \phpbb\db\driver\sqlite();
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $sqlite_db, new \phpbb\db\tools\tools($sqlite_db, true), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($sqlite_db, true);
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $sqlite_db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$db_table_schema = $schema_generator->get_schema();
|
||||
}
|
||||
|
||||
@ -1212,7 +1214,8 @@ class install_install extends module
|
||||
define('CONFIG_TABLE', $data['table_prefix'] . 'config');
|
||||
}
|
||||
|
||||
$db_tools = new \phpbb\db\tools\tools($db);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($db);
|
||||
foreach ($db_table_schema as $table_name => $table_data)
|
||||
{
|
||||
$db_tools->sql_create_table(
|
||||
|
@ -113,9 +113,9 @@ class qa
|
||||
*/
|
||||
public function is_installed()
|
||||
{
|
||||
global $db;
|
||||
global $phpbb_container;
|
||||
|
||||
$db_tool = new \phpbb\db\tools\tools($db);
|
||||
$db_tool = $phpbb_container->get('dbal.tools');
|
||||
|
||||
return $db_tool->sql_table_exists($this->table_captcha_questions);
|
||||
}
|
||||
@ -306,11 +306,9 @@ class qa
|
||||
*/
|
||||
function install()
|
||||
{
|
||||
global $db;
|
||||
global $phpbb_container;
|
||||
|
||||
$db_tool = new \phpbb\db\tools\tools($db);
|
||||
|
||||
$tables = array($this->table_captcha_questions, $this->table_captcha_answers, $this->table_qa_confirm);
|
||||
$db_tool = $phpbb_container->get('dbal.tools');
|
||||
|
||||
$schemas = array(
|
||||
$this->table_captcha_questions => array (
|
||||
@ -352,7 +350,7 @@ class qa
|
||||
),
|
||||
);
|
||||
|
||||
foreach($schemas as $table => $schema)
|
||||
foreach ($schemas as $table => $schema)
|
||||
{
|
||||
if (!$db_tool->sql_table_exists($table))
|
||||
{
|
||||
|
@ -136,7 +136,8 @@ class fulltext_sphinx
|
||||
$this->auth = $auth;
|
||||
|
||||
// Initialize \phpbb\db\tools\tools object
|
||||
$this->db_tools = new \phpbb\db\tools\tools($this->db);
|
||||
global $phpbb_container; // TODO inject into object
|
||||
$this->db_tools = $phpbb_container->get('dbal.tools');
|
||||
|
||||
if(!$this->config['fulltext_sphinx_id'])
|
||||
{
|
||||
|
@ -30,7 +30,8 @@ class phpbb_dbal_auto_increment_test extends phpbb_database_test_case
|
||||
parent::setUp();
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$this->tools = new \phpbb\db\tools\tools($this->db);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$this->tools = $factory->get($this->db);
|
||||
|
||||
$this->table_data = array(
|
||||
'COLUMNS' => array(
|
||||
|
@ -32,7 +32,8 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
|
||||
parent::setUp();
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$this->tools = new \phpbb\db\tools\tools($this->db);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$this->tools = $factory->get($this->db);
|
||||
|
||||
$this->table_data = array(
|
||||
'COLUMNS' => array(
|
||||
|
@ -38,7 +38,8 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
||||
parent::setUp();
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$this->db_tools = new \phpbb\db\tools\tools($this->db);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$this->db_tools = $factory->get($this->db);
|
||||
|
||||
$this->config = new \phpbb\config\db($this->db, new phpbb_mock_cache, 'phpbb_config');
|
||||
|
||||
|
@ -150,7 +150,8 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
|
||||
|
||||
$config = new \phpbb\config\config(array('version' => PHPBB_VERSION));
|
||||
$db = $this->new_dbal();
|
||||
$db_tools = new \phpbb\db\tools\tools($db);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($db);
|
||||
$phpbb_root_path = __DIR__ . './../../phpBB/';
|
||||
$php_ext = 'php';
|
||||
$table_prefix = 'phpbb_';
|
||||
|
@ -41,7 +41,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
|
||||
'version' => '3.1.0',
|
||||
));
|
||||
$this->db = $this->new_dbal();
|
||||
$this->db_tools = new \phpbb\db\tools\tools($this->db);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$this->db_tools = $factory->get($this->db);
|
||||
$this->phpbb_root_path = dirname(__FILE__) . '/';
|
||||
$this->phpEx = 'php';
|
||||
$this->user = new \phpbb\user('\phpbb\datetime');
|
||||
|
@ -18,7 +18,8 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
|
||||
public function getDataSet()
|
||||
{
|
||||
$this->db = $this->new_dbal();
|
||||
$db_tools = new \phpbb\db\tools\tools($this->db);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($this->db);
|
||||
|
||||
// user_dst doesn't exist anymore, must re-add it to test this
|
||||
$db_tools->sql_column_add('phpbb_users', 'user_dst', array('BOOL', 1));
|
||||
@ -55,11 +56,12 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
|
||||
$this->migration = new \phpbb\db\migration\data\v310\timezone(
|
||||
new \phpbb\config\config(array()),
|
||||
$this->db,
|
||||
new \phpbb\db\tools\tools($this->db),
|
||||
$factory->get($this->db),
|
||||
$phpbb_root_path,
|
||||
$phpEx,
|
||||
'phpbb_'
|
||||
@ -90,7 +92,8 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$db_tools = new \phpbb\db\tools\tools($this->db);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($this->db);
|
||||
|
||||
// Remove the user_dst field again
|
||||
$db_tools->sql_column_remove('phpbb_users', 'user_dst');
|
||||
|
@ -30,7 +30,8 @@ class schema_generator_test extends phpbb_test_case
|
||||
|
||||
$this->config = new \phpbb\config\config(array());
|
||||
$this->db = new \phpbb\db\driver\sqlite();
|
||||
$this->db_tools = new \phpbb\db\tools\tools($this->db);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$this->db_tools = $factory->get($this->db);
|
||||
$this->table_prefix = 'phpbb_';
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,12 @@ class phpbb_notification_convert_test extends phpbb_database_test_case
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
|
||||
$this->migration = new \phpbb\db\migration\data\v310\notification_options_reconvert(
|
||||
new \phpbb\config\config(array()),
|
||||
$this->db,
|
||||
new \phpbb\db\tools\tools($this->db),
|
||||
$factory->get($this->db),
|
||||
$phpbb_root_path,
|
||||
$phpEx,
|
||||
'phpbb_'
|
||||
|
@ -77,7 +77,10 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||
global $table_prefix;
|
||||
|
||||
$db = new \phpbb\db\driver\sqlite();
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($db, true);
|
||||
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix);
|
||||
file_put_contents(self::$schema_file, json_encode($schema_generator->get_schema()));
|
||||
}
|
||||
|
||||
|
@ -370,11 +370,15 @@ class phpbb_database_test_connection_manager
|
||||
->get_classes();
|
||||
|
||||
$db = new \phpbb\db\driver\sqlite();
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($db, true);
|
||||
|
||||
$schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix);
|
||||
$db_table_schema = $schema_generator->get_schema();
|
||||
}
|
||||
|
||||
$db_tools = new \phpbb\db\tools\tools($db, true);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($db, true);
|
||||
foreach ($db_table_schema as $table_name => $table_data)
|
||||
{
|
||||
$queries = $db_tools->sql_create_table(
|
||||
|
@ -230,7 +230,8 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
|
||||
$config = new \phpbb\config\config(array());
|
||||
$db = $this->get_db();
|
||||
$db_tools = new \phpbb\db\tools\tools($db);
|
||||
$factory = new \phpbb\db\tools\factory();
|
||||
$db_tools = $factory->get($db);
|
||||
|
||||
$container = new phpbb_mock_container_builder();
|
||||
$migrator = new \phpbb\db\migrator(
|
||||
|
Loading…
x
Reference in New Issue
Block a user