/** * {@inheritdoc} */ public function locate_resources() { if ($this->filesystem->exists($this->phpbb_root_path . 'install/update/new/config')) { $resources = array(array('install/update/new/config/' . $this->environment . '/routing/environment.yml', 'yaml')); } else { $resources = array(array('config/' . $this->environment . '/routing/environment.yml', 'yaml')); } return $resources; }
/** * {@inheritdoc} */ public function run() { // Generate database schema if ($this->filesystem->exists($this->phpbb_root_path . 'install/schemas/schema.json')) { $db_table_schema = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema.json'); $this->config->set('change_table_prefix', true); } else { global $table_prefix; // As this task may take a large amount of time to complete refreshing the page might be necessary for some // server configurations with limited resources if (!$this->config->get('pre_schema_forced_refresh', false)) { if ($this->config->get_time_remaining() < 5) { $this->config->set('pre_schema_forced_refresh', true); throw new resource_limit_reached_exception(); } } $table_prefix = $this->config->get('table_prefix'); if (!defined('CONFIG_TABLE')) { // We need to include the constants file for the table constants // when we generate the schema from the migration files. include $this->phpbb_root_path . 'includes/constants.' . $this->php_ext; } $finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, null, $this->php_ext); $migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes(); $factory = new \phpbb\db\tools\factory(); $db_tools = $factory->get($this->db, true); $schema_generator = new \phpbb\db\migration\schema_generator($migrator_classes, new \phpbb\config\config(array()), $this->db, $db_tools, $this->phpbb_root_path, $this->php_ext, $table_prefix); $db_table_schema = $schema_generator->get_schema(); $db_table_schema = json_encode($db_table_schema, JSON_PRETTY_PRINT); $this->config->set('change_table_prefix', false); } $fp = @fopen($this->phpbb_root_path . 'store/schema.json', 'wb'); if (!$fp) { throw new \Exception('INST_SCHEMA_FILE_NOT_WRITABLE'); } fwrite($fp, $db_table_schema); fclose($fp); }
/** * {@inheritdoc} */ public function check_requirements() { $dbms = $this->config->get('dbms'); $dbms_info = $this->database_helper->get_available_dbms($dbms); $schema_name = $dbms_info[$dbms]['SCHEMA']; if ($dbms === 'mysql') { if (version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) { $schema_name .= '_41'; } else { $schema_name .= '_40'; } } $this->schema_file_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql'; return $this->filesystem->exists($this->schema_file_path); }
/** * Recovers install configuration from file */ public function load_config() { if (!$this->filesystem->exists($this->install_config_file)) { return; } $file_content = @file_get_contents($this->install_config_file); $serialized_data = trim(substr($file_content, 8)); $this->installer_config = array(); $this->progress_data = array(); $this->navigation_data = array(); if (!empty($serialized_data)) { $unserialized_data = json_decode($serialized_data, true); $this->installer_config = is_array($unserialized_data['installer_config']) ? $unserialized_data['installer_config'] : array(); $this->progress_data = is_array($unserialized_data['progress_data']) ? $unserialized_data['progress_data'] : array(); $this->navigation_data = is_array($unserialized_data['navigation_data']) ? $unserialized_data['navigation_data'] : array(); } }
/** * {@inheritdoc} */ public function run() { $this->db->sql_return_on_error(true); $dbms = $this->config->get('dbms'); $dbms_info = $this->database_helper->get_available_dbms($dbms); $schema_name = $dbms_info[$dbms]['SCHEMA']; $delimiter = $dbms_info[$dbms]['DELIM']; $table_prefix = $this->config->get('table_prefix'); if ($dbms === 'mysql') { if (version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) { $schema_name .= '_41'; } else { $schema_name .= '_40'; } } $db_schema_path = $this->phpbb_root_path . 'install/schemas/' . $schema_name . '_schema.sql'; // Load database vendor specific code if there is any if ($this->filesystem->exists($db_schema_path)) { $sql_query = @file_get_contents($db_schema_path); $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query); $sql_query = $this->database_helper->remove_comments($sql_query); $sql_query = $this->database_helper->split_sql_file($sql_query, $delimiter); foreach ($sql_query as $sql) { if (!$this->db->sql_query($sql)) { $error = $this->db->sql_error($this->db->get_sql_error_sql()); $this->iohandler->add_error_message('INST_ERR_DB', $error['message']); } } unset($sql_query); } $change_prefix = false; // Generate database schema if ($this->filesystem->exists($this->phpbb_root_path . 'install/schemas/schema.json')) { $db_table_schema = @file_get_contents($this->phpbb_root_path . 'install/schemas/schema.json'); $db_table_schema = json_decode($db_table_schema, true); $change_prefix = true; } else { global $table_prefix; $table_prefix = $this->config->get('table_prefix'); if (!defined('CONFIG_TABLE')) { // We need to include the constants file for the table constants // when we generate the schema from the migration files. include $this->phpbb_root_path . 'includes/constants.' . $this->php_ext; } $finder = new \phpbb\finder($this->filesystem, $this->phpbb_root_path, null, $this->php_ext); $migrator_classes = $finder->core_path('phpbb/db/migration/data/')->get_classes(); $factory = new \phpbb\db\tools\factory(); $db_tools = $factory->get($this->db, true); $schema_generator = new \phpbb\db\migration\schema_generator($migrator_classes, new \phpbb\config\config(array()), $this->db, $db_tools, $this->phpbb_root_path, $this->php_ext, $table_prefix); $db_table_schema = $schema_generator->get_schema(); } if (!defined('CONFIG_TABLE')) { // CONFIG_TABLE is required by sql_create_index() to check the // length of index names. However table_prefix is not defined // here yet, so we need to create the constant ourselves. define('CONFIG_TABLE', $table_prefix . 'config'); } foreach ($db_table_schema as $table_name => $table_data) { $this->db_tools->sql_create_table($change_prefix ? $table_prefix . substr($table_name, 6) : $table_name, $table_data); } }