diff options
Diffstat (limited to 'phpBB/install/install_install.php')
| -rw-r--r-- | phpBB/install/install_install.php | 70 |
1 files changed, 50 insertions, 20 deletions
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 380f34bab6..e8890a3d08 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -43,9 +43,15 @@ if (!empty($setmodules)) */ class install_install extends module { + /** + * @var \phpbb\filesystem\filesystem_interface + */ + protected $filesystem; + function install_install(&$p_master) { $this->p_master = &$p_master; + $this->filesystem = new \phpbb\filesystem\filesystem(); } function main($mode, $sub) @@ -104,8 +110,8 @@ class install_install extends module $request->enable_super_globals(); // Create a normal container now - $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); - $phpbb_container = $phpbb_container_builder->get_container(); + $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); + $phpbb_container = $phpbb_container_builder->with_config($phpbb_config_php_file)->get_container(); // Sets the global variables /* @var $cache \phpbb\cache\service */ @@ -466,13 +472,29 @@ class install_install extends module if (!file_exists($phpbb_root_path . $dir)) { @mkdir($phpbb_root_path . $dir, 0777); - phpbb_chmod($phpbb_root_path . $dir, CHMOD_READ | CHMOD_WRITE); + + try + { + $this->filesystem->phpbb_chmod($phpbb_root_path . $dir, CHMOD_READ | CHMOD_WRITE); + } + catch (\phpbb\filesystem\exception\filesystem_exception $e) + { + // Do nothing + } } // Now really check if (file_exists($phpbb_root_path . $dir) && is_dir($phpbb_root_path . $dir)) { - phpbb_chmod($phpbb_root_path . $dir, CHMOD_READ | CHMOD_WRITE); + try + { + $this->filesystem->phpbb_chmod($phpbb_root_path . $dir, CHMOD_READ | CHMOD_WRITE); + } + catch (\phpbb\filesystem\exception\filesystem_exception $e) + { + // Do nothing + } + $exists = true; } @@ -514,7 +536,7 @@ class install_install extends module $write = $exists = true; if (file_exists($phpbb_root_path . $dir)) { - if (!phpbb_is_writable($phpbb_root_path . $dir)) + if (!$this->filesystem->is_writable($phpbb_root_path . $dir)) { $write = false; } @@ -892,7 +914,7 @@ class install_install extends module $config_data = phpbb_create_config_file_data($data, $available_dbms[$data['dbms']]['DRIVER']); // Attempt to write out the config file directly. If it works, this is the easiest way to do it ... - if ((file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx)) || phpbb_is_writable($phpbb_root_path)) + if ((file_exists($phpbb_root_path . 'config.' . $phpEx) && $this->filesystem->is_writable($phpbb_root_path . 'config.' . $phpEx)) || $this->filesystem->is_writable($phpbb_root_path)) { // Assume it will work ... if nothing goes wrong below $written = true; @@ -914,7 +936,14 @@ class install_install extends module if ($written) { // We may revert back to chmod() if we see problems with users not able to change their config.php file directly - phpbb_chmod($phpbb_root_path . 'config.' . $phpEx, CHMOD_READ); + try + { + $this->filesystem->phpbb_chmod($phpbb_root_path . 'config.' . $phpEx, CHMOD_READ); + } + catch (\phpbb\filesystem\exception\filesystem_exception $e) + { + // Do nothing + } } } @@ -1167,12 +1196,10 @@ class install_install extends module foreach ($sql_query as $sql) { - //$sql = trim(str_replace('|', ';', $sql)); - if (!$db->sql_query($sql)) - { - $error = $db->sql_error(); - $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__); - } + // Ignore errors when the functions or types already exist + // to allow installing phpBB twice in the same database with + // a different prefix + $db->sql_query($sql); } unset($sql_query); } @@ -1195,12 +1222,14 @@ class install_install extends module include($phpbb_root_path . 'includes/constants.' . $phpEx); } - $finder = new \phpbb\finder(new \phpbb\filesystem(), $phpbb_root_path, null, $phpEx); + $finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), $phpbb_root_path, null, $phpEx); $classes = $finder->core_path('phpbb/db/migration/data/') ->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 +1241,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( @@ -1492,7 +1522,7 @@ class install_install extends module include_once($phpbb_root_path . 'phpbb/search/fulltext_native.' . $phpEx); // We need to fill the config to let internal functions correctly work - $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); + $config = new \phpbb\config\db($db, new \phpbb\cache\driver\dummy, CONFIG_TABLE); $error = false; $search = new \phpbb\search\fulltext_native($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); @@ -1907,7 +1937,7 @@ class install_install extends module $data = $this->get_submitted_data(); // We need to fill the config to let internal functions correctly work - $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); + $config = new \phpbb\config\db($db, new \phpbb\cache\driver\dummy, CONFIG_TABLE); $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " @@ -1979,7 +2009,7 @@ class install_install extends module $data = $this->get_submitted_data(); // We need to fill the config to let internal functions correctly work - $config = new \phpbb\config\db($db, new \phpbb\cache\driver\null, CONFIG_TABLE); + $config = new \phpbb\config\db($db, new \phpbb\cache\driver\dummy, CONFIG_TABLE); $user->session_begin(); $auth->login($data['admin_name'], $data['admin_pass1'], false, true, true); @@ -2028,7 +2058,7 @@ class install_install extends module { global $config, $phpbb_root_path; - if (!phpbb_is_writable($phpbb_root_path . 'images/avatars/upload/')) + if (!$this->filesystem->is_writable($phpbb_root_path . 'images/avatars/upload/')) { $config->set('allow_avatar', 0); $config->set('allow_avatar_upload', 0); |
