mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-08 00:25:19 +02:00
[feature/migrations] Move migrator to service container
Version numbers 3.1 updates Restore database_update.php file to what it was in develop Get first forum to place global announcements in PHPBB3-9737
This commit is contained in:
parent
41de95bc11
commit
6c44dadecb
@ -94,6 +94,12 @@ services:
|
||||
calls:
|
||||
- [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]]
|
||||
|
||||
dbal.tools:
|
||||
file: %core.root_path%includes/db/db_tools.%core.php_ext%
|
||||
class: phpbb_db_tools
|
||||
arguments:
|
||||
- @dbal.conn
|
||||
|
||||
event.subscriber_loader:
|
||||
class: phpbb_event_extension_subscriber_loader
|
||||
arguments:
|
||||
@ -156,6 +162,45 @@ services:
|
||||
tags:
|
||||
- { name: kernel.event_subscriber }
|
||||
|
||||
migrator:
|
||||
class: phpbb_db_migrator
|
||||
arguments:
|
||||
- @service_container
|
||||
|
||||
migrator.tools_collection
|
||||
class: phpbb_di_service_collection
|
||||
arguments:
|
||||
- @service_container
|
||||
|
||||
migrator.tools.config:
|
||||
class: phpbb_db_migration_tools_config
|
||||
arguments:
|
||||
- @config
|
||||
tags:
|
||||
- { name: migrator:tool }
|
||||
|
||||
migrator.tools.module:
|
||||
class: phpbb_db_migration_tools_module
|
||||
arguments:
|
||||
- @db
|
||||
- @cache
|
||||
- @user
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
tags:
|
||||
- { name: migrator:tool }
|
||||
|
||||
migrator.tools.permission:
|
||||
class: phpbb_db_migration_tools_permission
|
||||
arguments:
|
||||
- @db
|
||||
- @cache
|
||||
- @auth
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
tags:
|
||||
- { name: migrator:tool }
|
||||
|
||||
request:
|
||||
class: phpbb_request
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
parameters:
|
||||
tables.config: %core.table_prefix%config
|
||||
tables.ext: %core.table_prefix%ext
|
||||
tables.migrations: %core.table_prefix%migrations
|
||||
|
@ -1258,7 +1258,7 @@ function get_schema_struct()
|
||||
),
|
||||
);
|
||||
|
||||
$schema_data['phpbb_moderator_cache'] = array(
|
||||
$schema_data['phpbb_migrations'] = array(
|
||||
'COLUMNS' => array(
|
||||
'forum_id' => array('UINT', 0),
|
||||
'user_id' => array('UINT', 0),
|
||||
@ -1273,6 +1273,18 @@ function get_schema_struct()
|
||||
),
|
||||
);
|
||||
|
||||
$schema_data['phpbb_moderator_cache'] = array(
|
||||
'COLUMNS' => array(
|
||||
'migration_name' => array('VCHAR', ''),
|
||||
'migration_schema_done' => array('BOOL', 0),
|
||||
'migration_data_done' => array('BOOL', 0),
|
||||
'migration_data_state' => array('TEXT', ''),
|
||||
'migration_start_time' => array('TIMESTAMP', 0),
|
||||
'migration_end_time' => array('TIMESTAMP', 0),
|
||||
),
|
||||
'PRIMARY_KEY' => 'migration_name',
|
||||
);
|
||||
|
||||
$schema_data['phpbb_modules'] = array(
|
||||
'COLUMNS' => array(
|
||||
'module_id' => array('UINT', NULL, 'auto_increment'),
|
||||
|
@ -345,6 +345,16 @@ class phpbb_db_tools
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for {@link $return_statements return_statements}.
|
||||
*
|
||||
* @param bool $return_statements True if SQL should not be executed but returned as strings
|
||||
*/
|
||||
public function set_return_statements($return_statements)
|
||||
{
|
||||
$this->return_statements = $return_statements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of tables in the database.
|
||||
*
|
||||
|
@ -26,6 +26,7 @@ if (!defined('IN_PHPBB'))
|
||||
*/
|
||||
class phpbb_db_migration
|
||||
{
|
||||
protected $config;
|
||||
protected $db;
|
||||
protected $db_tools;
|
||||
protected $table_prefix;
|
||||
@ -38,20 +39,17 @@ class phpbb_db_migration
|
||||
/**
|
||||
* Migration constructor
|
||||
*
|
||||
* @param dbal $db Connected database abstraction instance
|
||||
* @param phpbb_db_tools $db_tools Instance of db schema manipulation tools
|
||||
* @param string $table_prefix The prefix for all table names
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $php_ext
|
||||
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container Container supplying dependencies
|
||||
*/
|
||||
public function phpbb_db_migration($db, $db_tools, $table_prefix, $phpbb_root_path, $php_ext)
|
||||
public function phpbb_db_migration(\Symfony\Component\DependencyInjection\ContainerInterface $container)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->db_tools = $db_tools;
|
||||
$this->table_prefix = $table_prefix;
|
||||
$this->config = $this->container->get('config');
|
||||
$this->db = $this->container->get('dbal.conn');
|
||||
$this->db_tools = $this->container->get('dbal.tools');
|
||||
$this->table_prefix = $this->container->getParameters('core.table_prefix');
|
||||
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->phpbb_root_path = $this->container->getParameters('core.root_path');
|
||||
$this->php_ext = $this->container->getParameters('core.php_ext');
|
||||
|
||||
$this->errors = array();
|
||||
}
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_1 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.1')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_10 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.10')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ class phpbb_db_migration_data_3_0_10_rc1 extends phpbb_db_migration
|
||||
{
|
||||
return array(
|
||||
array('config.add', array('email_max_chunk_size', 50)),
|
||||
|
||||
array('config.update', array('version', '3.0.10-rc1')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_10_rc2 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.10-rc2')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_10_rc3 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.10-rc3')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_11 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.11')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ class phpbb_db_migration_data_3_0_11_rc1 extends phpbb_db_migration
|
||||
return array(
|
||||
array('custom', array(array(&$this, 'cleanup_deactivated_styles'))),
|
||||
array('custom', array(array(&$this, 'delete_orphan_private_messages'))),
|
||||
|
||||
array('config.update', array('version', '3.0.11-rc1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -27,5 +27,8 @@ class phpbb_db_migration_data_3_0_11_rc2 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.11-rc2')),
|
||||
);
|
||||
}
|
||||
}
|
@ -7,6 +7,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 **/
|
||||
|
||||
/*
|
||||
class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration
|
||||
{
|
||||
function depends_on()
|
||||
@ -16,11 +19,14 @@ class phpbb_db_migration_data_3_0_12_rc1 extends phpbb_db_migration
|
||||
|
||||
function update_schema()
|
||||
{
|
||||
/** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 */
|
||||
return array();
|
||||
}
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.12-rc1')),
|
||||
);
|
||||
}
|
||||
}
|
||||
*/
|
@ -44,6 +44,8 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration
|
||||
return array(
|
||||
array('custom', array(array(&$this, 'fix_unset_last_view_time'))),
|
||||
array('custom', array(array(&$this, 'reset_smiley_size'))),
|
||||
|
||||
array('config.update', array('version', '3.0.1-rc1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_2 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.2')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration
|
||||
class phpbb_db_migration_data_3_0_2_rc1 extends phpbb_db_migration
|
||||
{
|
||||
function depends_on()
|
||||
{
|
||||
@ -25,6 +25,8 @@ class phpbb_db_migration_data_3_0_1_rc1 extends phpbb_db_migration
|
||||
array('config.add', array('referer_validation', '1')),
|
||||
array('config.add', array('check_attachment_content', '1')),
|
||||
array('config.add', array('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title')),
|
||||
|
||||
array('config.update', array('version', '3.0.2-rc1')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -48,5 +48,8 @@ class phpbb_db_migration_data_3_0_2_rc2 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.2-rc2')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration
|
||||
{
|
||||
function depends_on()
|
||||
{
|
||||
return array('phpbb_db_migration_data_3_0_2_rc2');
|
||||
return array('phpbb_db_migration_data_3_0_3_rc1');
|
||||
}
|
||||
|
||||
function update_schema()
|
||||
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_3 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.3')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ class phpbb_db_migration_data_3_0_3_rc1 extends phpbb_db_migration
|
||||
array('config.add', array('dbms_version', '')),
|
||||
array('permission.add', array('u_masspm_group', phpbb_auth::IS_GLOBAL),
|
||||
array('custom', array(array(&$this, 'correct_acp_email_permissions'))),
|
||||
|
||||
array('config.update', array('version', '3.0.3-rc1')),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,8 @@ class phpbb_db_migration_data_3_0_4 extends phpbb_db_migration
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array(&$this, 'rename_log_delete_topic'))),
|
||||
|
||||
array('config.update', array('version', '3.0.4')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,8 @@ class phpbb_db_migration_data_3_0_4_rc1 extends phpbb_db_migration
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array(&$this, 'update_custom_profile_fields'))),
|
||||
|
||||
array('config.update', array('version', '3.0.4-rc1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_5 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.5')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -30,5 +30,8 @@ class phpbb_db_migration_data_3_0_5_rc1part2 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.5-rc1')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_6 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.6')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -155,6 +155,8 @@ class phpbb_db_migration_data_3_0_6_rc1 extends phpbb_db_migration
|
||||
)),
|
||||
array('custom', array(array(&$this, 'add_newly_registered_group'))),
|
||||
array('custom', array(array(&$this, 'set_user_options_default'))),
|
||||
|
||||
array('config.update', array('version', '3.0.6-rc1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_6_rc2 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.6-rc2')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ class phpbb_db_migration_data_3_0_6_rc3 extends phpbb_db_migration
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array(&$this, 'update_cp_fields'))),
|
||||
|
||||
array('config.update', array('version', '3.0.6-rc3')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_6_rc4 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.6-rc4')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_7 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.7')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_7_pl1 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.7-pl1')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ class phpbb_db_migration_data_3_0_7_rc1 extends phpbb_db_migration
|
||||
array('config.add', array('feed_topics_new', $this->config['feed_overall_topics'])),
|
||||
array('config.add', array('feed_topics_active', $this->config['feed_overall_topics'])),
|
||||
array('custom', array(array(&$this, 'delete_text_templates'))),
|
||||
|
||||
array('config.update', array('version', '3.0.7-rc1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,8 @@ class phpbb_db_migration_data_3_0_7_rc2 extends phpbb_db_migration
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array(&$this, 'update_email_hash'))),
|
||||
|
||||
array('config.update', array('version', '3.0.7-rc2')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_8 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.8')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ class phpbb_db_migration_data_3_0_8_rc1 extends phpbb_db_migration
|
||||
array('config.add', array('load_unreads_search', 1)),
|
||||
array('config.update_if_equals', array(600, 'queue_interval', 60)),
|
||||
array('config.update_if_equals', array(50, 'email_package_size', 20)),
|
||||
|
||||
array('config.update', array('version', '3.0.8-rc1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_9 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.9')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ class phpbb_db_migration_data_3_0_9_rc1 extends phpbb_db_migration
|
||||
array('config.add', array('ip_login_limit_use_forwarded', 0)),
|
||||
array('custom', array(array(&$this, 'update_file_extension_group_names'))),
|
||||
array('custom', array(array(&$this, 'fix_firebird_qa_captcha'))),
|
||||
|
||||
array('config.update', array('version', '3.0.9-rc1')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_9_rc2 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.9-rc2')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_9_rc3 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.9-rc3')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,8 @@ class phpbb_db_migration_data_3_0_9_rc4 extends phpbb_db_migration
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('version', '3.0.9-rc4')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
283
phpBB/includes/db/migration/data/3_1_0_dev.php
Normal file
283
phpBB/includes/db/migration/data/3_1_0_dev.php
Normal file
@ -0,0 +1,283 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_data_extensions extends phpbb_db_migration
|
||||
{
|
||||
public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'phpbb_db_migration_data_3_0_11',
|
||||
'phpbb_db_migration_data_extensions',
|
||||
'phpbb_db_migration_data_style_update_p2',
|
||||
'phpbb_db_migration_data_timezone',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return array(
|
||||
'add_columns' => array(
|
||||
GROUPS_TABLE => array(
|
||||
'group_teampage' => array('UINT', 0, 'after' => 'group_legend'),
|
||||
),
|
||||
PROFILE_FIELDS_TABLE => array(
|
||||
'field_show_on_pm' => array('BOOL', 0),
|
||||
),
|
||||
STYLES_TABLE => array(
|
||||
'style_path' => array('VCHAR:100', ''),
|
||||
'bbcode_bitfield' => array('VCHAR:255', 'kNg='),
|
||||
'style_parent_id' => array('UINT:4', 0),
|
||||
'style_parent_tree' => array('TEXT', ''),
|
||||
),
|
||||
REPORTS_TABLE => array(
|
||||
'reported_post_text' => array('MTEXT_UNI', ''),
|
||||
'reported_post_uid' => array('VCHAR:8', ''),
|
||||
'reported_post_bitfield' => array('VCHAR:255', ''),
|
||||
),
|
||||
),
|
||||
'change_columns' => array(
|
||||
GROUPS_TABLE => array(
|
||||
'group_legend' => array('UINT', 0),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])),
|
||||
|
||||
array('config.add', array('fulltext_postgres_ts_name', 'simple')),
|
||||
array('config.add', array('fulltext_postgres_min_word_len', 4)),
|
||||
array('config.add', array('fulltext_postgres_max_word_len', 254)),
|
||||
array('config.add', array('fulltext_sphinx_stopwords', 0)),
|
||||
array('config.add', array('fulltext_sphinx_indexer_mem_limit', 512)),
|
||||
|
||||
array('config.add', array('load_jquery_cdn', 0)),
|
||||
array('config.add', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js')),
|
||||
|
||||
array('config.add', array('use_system_cron', 0)),
|
||||
|
||||
array('config.add', array('legend_sort_groupname', 0)),
|
||||
array('config.add', array('teampage_forums', 1)),
|
||||
array('config.add', array('teampage_memberships', 1)),
|
||||
|
||||
array('config.add', array('load_cpf_pm', 0)),
|
||||
|
||||
array('config.add', array('display_last_subject', 1)),
|
||||
|
||||
array('config.add', array('assets_version', 1)),
|
||||
|
||||
array('config.add', array('site_home_url', '')),
|
||||
array('config.add', array('site_home_text', '')),
|
||||
|
||||
array('module.add', array(
|
||||
'acp',
|
||||
'ACP_GROUPS',
|
||||
array(
|
||||
'module_basename' => 'acp_groups',
|
||||
'modes' => array('position'),
|
||||
),
|
||||
)),
|
||||
array('module.add', array(
|
||||
'acp',
|
||||
'ACP_ATTACHMENTS',
|
||||
array(
|
||||
'module_basename' => 'acp_attachments',
|
||||
'modes' => array('manage'),
|
||||
),
|
||||
)),
|
||||
array('module.add', array(
|
||||
'acp',
|
||||
'ACP_STYLE_MANAGEMENT',
|
||||
array(
|
||||
'module_basename' => 'acp_styles',
|
||||
'modes' => array('install', 'cache'),
|
||||
),
|
||||
)),
|
||||
array('module.add', array(
|
||||
'acp',
|
||||
'UCP_PROFILE',
|
||||
array(
|
||||
'module_basename' => 'ucp_profile',
|
||||
'modes' => array('autologin_keys'),
|
||||
),
|
||||
)),
|
||||
|
||||
array('module.remove', array(
|
||||
'acp',
|
||||
'ACP_CAT_STYLES',
|
||||
array(
|
||||
'module_basename' => 'styles',
|
||||
'modes' => array('imageset', 'theme', 'template'),
|
||||
),
|
||||
)),
|
||||
|
||||
array('custom', array(array($this, 'rename_module_basenames'))),
|
||||
array('custom', array(array($this, 'add_group_teampage'))),
|
||||
array('custom', array(array($this, 'update_group_legend'))),
|
||||
array('custom', array(array($this, 'localise_global_announcements'))),
|
||||
);
|
||||
}
|
||||
|
||||
public function rename_module_basenames()
|
||||
{
|
||||
// rename all module basenames to full classname
|
||||
$sql = 'SELECT module_id, module_basename, module_class
|
||||
FROM ' . MODULES_TABLE;
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$module_id = (int) $row['module_id'];
|
||||
unset($row['module_id']);
|
||||
|
||||
if (!empty($row['module_basename']) && !empty($row['module_class']))
|
||||
{
|
||||
// all the class names start with class name or with phpbb_ for auto loading
|
||||
if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 &&
|
||||
strpos($row['module_basename'], 'phpbb_') !== 0)
|
||||
{
|
||||
$row['module_basename'] = $row['module_class'] . '_' . $row['module_basename'];
|
||||
|
||||
$sql_update = $this->db->sql_build_array('UPDATE', $row);
|
||||
|
||||
$sql = 'UPDATE ' . MODULES_TABLE . '
|
||||
SET ' . $sql_update . '
|
||||
WHERE module_id = ' . $module_id;
|
||||
$this->sql_query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
public function add_group_teampage()
|
||||
{
|
||||
$sql = 'UPDATE ' . GROUPS_TABLE . '
|
||||
SET group_teampage = 1
|
||||
WHERE group_type = ' . GROUP_SPECIAL . "
|
||||
AND group_name = 'ADMINISTRATORS'";
|
||||
$this->sql_query($sql);
|
||||
|
||||
$sql = 'UPDATE ' . GROUPS_TABLE . '
|
||||
SET group_teampage = 2
|
||||
WHERE group_type = ' . GROUP_SPECIAL . "
|
||||
AND group_name = 'GLOBAL_MODERATORS'";
|
||||
$this->sql_query($sql);
|
||||
}
|
||||
|
||||
public function update_group_legend()
|
||||
{
|
||||
$sql = 'SELECT group_id
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
WHERE group_legend = 1
|
||||
ORDER BY group_name ASC';
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
$next_legend = 1;
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$sql = 'UPDATE ' . GROUPS_TABLE . '
|
||||
SET group_legend = ' . $next_legend . '
|
||||
WHERE group_id = ' . (int) $row['group_id'];
|
||||
$this->sql_query($sql);
|
||||
|
||||
$next_legend++;
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
public function localise_global_announcements()
|
||||
{
|
||||
// Localise Global Announcements
|
||||
$sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour
|
||||
FROM ' . TOPICS_TABLE . '
|
||||
WHERE forum_id = 0
|
||||
AND topic_type = ' . POST_GLOBAL;
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
$global_announcements = $update_lastpost_data = array();
|
||||
$update_lastpost_data['forum_last_post_time'] = 0;
|
||||
$update_forum_data = array(
|
||||
'forum_posts' => 0,
|
||||
'forum_topics' => 0,
|
||||
'forum_topics_real' => 0,
|
||||
);
|
||||
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$global_announcements[] = (int) $row['topic_id'];
|
||||
|
||||
$update_forum_data['forum_posts'] += (int) $row['topic_posts'];
|
||||
$update_forum_data['forum_topics_real']++;
|
||||
if ($row['topic_approved'])
|
||||
{
|
||||
$update_forum_data['forum_topics']++;
|
||||
}
|
||||
|
||||
if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time'])
|
||||
{
|
||||
$update_lastpost_data = array(
|
||||
'forum_last_post_id' => (int) $row['topic_last_post_id'],
|
||||
'forum_last_post_subject' => $row['topic_last_post_subject'],
|
||||
'forum_last_post_time' => (int) $row['topic_last_post_time'],
|
||||
'forum_last_poster_id' => (int) $row['topic_last_poster_id'],
|
||||
'forum_last_poster_name' => $row['topic_last_poster_name'],
|
||||
'forum_last_poster_colour' => $row['topic_last_poster_colour'],
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if (!empty($global_announcements))
|
||||
{
|
||||
// Update the post/topic-count for the forum and the last-post if needed
|
||||
$sql = 'SELECT forum_id
|
||||
FROM ' . FORUMS_TABLE . '
|
||||
WHERE forum_type = ' . FORUM_POST;
|
||||
$result = $this->db->sql_query_limit($sql, 1);
|
||||
$ga_forum_id = $this->db->sql_fetchfield('forum_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$sql = 'SELECT forum_last_post_time
|
||||
FROM ' . FORUMS_TABLE . '
|
||||
WHERE forum_id = ' . $ga_forum_id;
|
||||
$result = $this->db->sql_query($sql);
|
||||
$lastpost = (int) $this->db->sql_fetchfield('forum_last_post_time');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', ';
|
||||
$sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', ';
|
||||
$sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics'];
|
||||
if ($lastpost < $update_lastpost_data['forum_last_post_time'])
|
||||
{
|
||||
$sql_update .= ', ' . $this->db->sql_build_array('UPDATE', $update_lastpost_data);
|
||||
}
|
||||
|
||||
$sql = 'UPDATE ' . FORUMS_TABLE . '
|
||||
SET ' . $sql_update . '
|
||||
WHERE forum_id = ' . $ga_forum_id;
|
||||
$this->sql_query($sql);
|
||||
|
||||
// Update some forum_ids
|
||||
$table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
|
||||
foreach ($table_ary as $table)
|
||||
{
|
||||
$sql = "UPDATE $table
|
||||
SET forum_id = $ga_forum_id
|
||||
WHERE " . $this->db->sql_in_set('topic_id', $global_announcements);
|
||||
$this->sql_query($sql);
|
||||
}
|
||||
unset($table_ary);
|
||||
}
|
||||
}
|
||||
}
|
48
phpBB/includes/db/migration/data/extensions.php
Normal file
48
phpBB/includes/db/migration/data/extensions.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_data_extensions extends phpbb_db_migration
|
||||
{
|
||||
public function depends_on()
|
||||
{
|
||||
return array('phpbb_db_migration_data_3_0_11');
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return array(
|
||||
'add_tables' => array(
|
||||
EXT_TABLE => array(
|
||||
'COLUMNS' => array(
|
||||
'ext_name' => array('VCHAR', ''),
|
||||
'ext_active' => array('BOOL', 0),
|
||||
'ext_state' => array('TEXT', ''),
|
||||
),
|
||||
'KEYS' => array(
|
||||
'ext_name' => array('UNIQUE', 'ext_name'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('module.add', array(
|
||||
'acp',
|
||||
'ACP_GENERAL_TASKS',
|
||||
array(
|
||||
'module_basename' => 'extensions',
|
||||
'modes' => array('main'),
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
99
phpBB/includes/db/migration/data/style_update_p1.php
Normal file
99
phpBB/includes/db/migration/data/style_update_p1.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_data_style_update_p1 extends phpbb_db_migration
|
||||
{
|
||||
public function depends_on()
|
||||
{
|
||||
return array('phpbb_db_migration_data_3_0_11');
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array($this, 'styles_update'))),
|
||||
);
|
||||
}
|
||||
|
||||
public function styles_update()
|
||||
{
|
||||
// Get list of valid 3.1 styles
|
||||
$available_styles = array('prosilver');
|
||||
|
||||
$iterator = new DirectoryIterator($phpbb_root_path . 'styles');
|
||||
$skip_dirs = array('.', '..', 'prosilver');
|
||||
foreach ($iterator as $fileinfo)
|
||||
{
|
||||
if ($fileinfo->isDir() && !in_array($fileinfo->getFilename(), $skip_dirs) && file_exists($fileinfo->getPathname() . '/style.cfg'))
|
||||
{
|
||||
$style_cfg = parse_cfg_file($fileinfo->getPathname() . '/style.cfg');
|
||||
if (isset($style_cfg['phpbb_version']) && version_compare($style_cfg['phpbb_version'], '3.1.0-dev', '>='))
|
||||
{
|
||||
// 3.1 style
|
||||
$available_styles[] = $fileinfo->getFilename();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get all installed styles
|
||||
if ($this->db_tools->sql_table_exists(STYLES_IMAGESET_TABLE))
|
||||
{
|
||||
$sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path
|
||||
FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i
|
||||
WHERE t.template_id = s.template_id
|
||||
AND c.theme_id = s.theme_id
|
||||
AND i.imageset_id = s.imageset_id";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id
|
||||
FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . " c
|
||||
WHERE t.template_id = s.template_id
|
||||
AND c.theme_id = s.theme_id";
|
||||
}
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
$styles = array();
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$styles[] = $row;
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
// Decide which styles to keep, all others will be deleted
|
||||
$valid_styles = array();
|
||||
foreach ($styles as $style_row)
|
||||
{
|
||||
if (
|
||||
// Delete styles with parent style (not supported yet)
|
||||
$style_row['template_inherits_id'] == 0 &&
|
||||
// Check if components match
|
||||
$style_row['template_path'] == $style_row['theme_path'] && (!isset($style_row['imageset_path']) || $style_row['template_path'] == $style_row['imageset_path']) &&
|
||||
// Check if components are valid
|
||||
in_array($style_row['template_path'], $available_styles)
|
||||
)
|
||||
{
|
||||
// Valid style. Keep it
|
||||
$sql_ary = array(
|
||||
'style_path' => $style_row['template_path'],
|
||||
'bbcode_bitfield' => $style_row['bbcode_bitfield'],
|
||||
'style_parent_id' => 0,
|
||||
'style_parent_tree' => '',
|
||||
);
|
||||
$this->sql_query('UPDATE ' . STYLES_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE style_id = ' . $style_row['style_id'], $errored, $error_ary);
|
||||
$valid_styles[] = (int) $style_row['style_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
83
phpBB/includes/db/migration/data/style_update_p2.php
Normal file
83
phpBB/includes/db/migration/data/style_update_p2.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_data_style_update_p2 extends phpbb_db_migration
|
||||
{
|
||||
public function depends_on()
|
||||
{
|
||||
return array('phpbb_db_migration_data_style_update_p1');
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return array(
|
||||
'drop_columns' => array(
|
||||
STYLES_TABLE => array(
|
||||
'imageset_id',
|
||||
'template_id',
|
||||
'theme_id',
|
||||
),
|
||||
),
|
||||
|
||||
'drop_tables' => array(
|
||||
STYLES_IMAGESET_TABLE,
|
||||
STYLES_IMAGESET_DATA_TABLE,
|
||||
STYLES_TEMPLATE_TABLE,
|
||||
STYLES_TEMPLATE_DATA_TABLE,
|
||||
STYLES_THEME_TABLE,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array($this, 'styles_update'))),
|
||||
);
|
||||
}
|
||||
|
||||
public function styles_update()
|
||||
{
|
||||
// Remove old entries from styles table
|
||||
if (!sizeof($valid_styles))
|
||||
{
|
||||
// No valid styles: remove everything and add prosilver
|
||||
$this->sql_query('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary);
|
||||
|
||||
$sql = 'INSERT INTO ' . STYLES_TABLE . " (style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES ('prosilver', '© phpBB Group', 1, 'prosilver', 'kNg=', 0, '')";
|
||||
$this->sql_query($sql);
|
||||
|
||||
$sql = 'SELECT style_id
|
||||
FROM ' . $table . "
|
||||
WHERE style_name = 'prosilver'";
|
||||
$result = $this->sql_query($sql);
|
||||
$default_style = $this->db->sql_fetchfield($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
set_config('default_style', $default_style);
|
||||
|
||||
$sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0';
|
||||
$this->sql_query($sql);
|
||||
}
|
||||
else
|
||||
{
|
||||
// There are valid styles in styles table. Remove styles that are outdated
|
||||
$this->sql_query('DELETE FROM ' . STYLES_TABLE . ' WHERE ' . $this->db->sql_in_set('style_id', $valid_styles, true), $errored, $error_ary);
|
||||
|
||||
// Change default style
|
||||
if (!in_array($config['default_style'], $valid_styles))
|
||||
{
|
||||
set_config('default_style', $valid_styles[0]);
|
||||
}
|
||||
|
||||
// Reset styles for users
|
||||
$this->sql_query('UPDATE ' . USERS_TABLE . ' SET user_style = 0 WHERE ' . $this->db->sql_in_set('user_style', $valid_styles, true), $errored, $error_ary);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @package migration
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* phpBB Update Helpers
|
||||
*/
|
||||
class phpbb_update_helpers
|
||||
class phpbb_db_migration_data_timezone extends phpbb_db_migration
|
||||
{
|
||||
public function depends_on()
|
||||
{
|
||||
return array('phpbb_db_migration_data_3_0_11');
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return array(
|
||||
'change_columns' => array(
|
||||
USERS_TABLE => array(
|
||||
'user_timezone' => array('VCHAR:100', ''),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array($this, 'update_timezones'))),
|
||||
);
|
||||
}
|
||||
|
||||
public function update_timezones()
|
||||
{
|
||||
// Update user timezones
|
||||
$sql = 'SELECT user_dst, user_timezone
|
||||
FROM ' . USERS_TABLE . '
|
||||
GROUP BY user_timezone, user_dst';
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$sql = 'UPDATE ' . USERS_TABLE . "
|
||||
SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "'
|
||||
WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "'
|
||||
AND user_dst = " . (int) $row['user_dst'];
|
||||
$this->sql_query($sql);
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
// Update board default timezone
|
||||
set_config('board_timezone', $this->convert_phpbb30_timezone($config['board_timezone'], $config['board_dst']));
|
||||
|
||||
// After we have calculated the timezones we can delete user_dst column from user table.
|
||||
$this->db_tools->sql_column_remove(USERS_TABLE, 'user_dst');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the new timezone for a given phpBB 3.0 timezone and
|
||||
* "Daylight Saving Time" option
|
||||
@ -19,7 +65,7 @@ class phpbb_update_helpers
|
||||
* @param $dst int Users daylight saving time
|
||||
* @return string Users new php Timezone which is used since 3.1
|
||||
*/
|
||||
function convert_phpbb30_timezone($timezone, $dst)
|
||||
public function convert_phpbb30_timezone($timezone, $dst)
|
||||
{
|
||||
$offset = $timezone + $dst;
|
||||
|
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_tools_base
|
||||
{
|
||||
/** @var phpbb_auth */
|
||||
protected $auth = null;
|
||||
|
||||
/** @var phpbb_cache_service */
|
||||
protected $cache = null;
|
||||
|
||||
/** @var phpbb_config */
|
||||
protected $config = null;
|
||||
|
||||
/** @var dbal */
|
||||
protected $db = null;
|
||||
|
||||
/** @var phpbb_template */
|
||||
protected $template = null;
|
||||
|
||||
/** @var phpbb_user */
|
||||
protected $user = null;
|
||||
|
||||
/** @var string */
|
||||
protected $phpbb_root_path = null;
|
||||
|
||||
/** @var string */
|
||||
protected $php_ext = null;
|
||||
|
||||
public function __construct(dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->cache = $cache;
|
||||
$this->template = $template;
|
||||
$this->user = $user;
|
||||
$this->auth = $auth;
|
||||
$this->config = $config;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
}
|
@ -7,20 +7,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_tools_config extends phpbb_db_migration_tools_base
|
||||
class phpbb_db_migration_tools_config
|
||||
{
|
||||
/**
|
||||
* Config Exists
|
||||
*
|
||||
* This function is to check to see if a config variable exists or if it does not.
|
||||
*
|
||||
* @param string $config_name The name of the config setting you wish to check for.
|
||||
*
|
||||
* @return bool true/false if config exists
|
||||
*/
|
||||
public function exists($config_name)
|
||||
/** @var phpbb_config */
|
||||
protected $config = null;
|
||||
|
||||
public function __construct(phpbb_config $config)
|
||||
{
|
||||
return (bool) $this->config->offsetExists($config_name);
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,7 +28,7 @@ class phpbb_db_migration_tools_config extends phpbb_db_migration_tools_base
|
||||
*/
|
||||
public function add($config_name, $config_value = '', $is_dynamic = false)
|
||||
{
|
||||
if ($this->config_exists($config_name))
|
||||
if (isset($this->config[$config_name]))
|
||||
{
|
||||
throw new phpbb_db_migration_exception('CONFIG_ALREADY_EXISTS', $config_name);
|
||||
}
|
||||
@ -54,7 +48,7 @@ class phpbb_db_migration_tools_config extends phpbb_db_migration_tools_base
|
||||
*/
|
||||
public function update($config_name, $config_value = '')
|
||||
{
|
||||
if (!$this->config_exists($config_name))
|
||||
if (!isset($this->config[$config_name]))
|
||||
{
|
||||
throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name);
|
||||
}
|
||||
@ -75,7 +69,7 @@ class phpbb_db_migration_tools_config extends phpbb_db_migration_tools_base
|
||||
*/
|
||||
public function update_if_equals($compare, $config_name, $config_value = '')
|
||||
{
|
||||
if (!$this->config_exists($config_name))
|
||||
if (!isset($this->config[$config_name]))
|
||||
{
|
||||
throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name);
|
||||
}
|
||||
@ -94,7 +88,7 @@ class phpbb_db_migration_tools_config extends phpbb_db_migration_tools_base
|
||||
*/
|
||||
public function remove($config_name)
|
||||
{
|
||||
if (!$this->config_exists($config_name))
|
||||
if (!isset($this->config[$config_name]))
|
||||
{
|
||||
throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name);
|
||||
}
|
||||
|
@ -7,8 +7,32 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_tools_module extends phpbb_db_migration_tools_base
|
||||
class phpbb_db_migration_tools_module
|
||||
{
|
||||
/** @var phpbb_cache_service */
|
||||
protected $cache = null;
|
||||
|
||||
/** @var dbal */
|
||||
protected $db = null;
|
||||
|
||||
/** @var phpbb_user */
|
||||
protected $user = null;
|
||||
|
||||
/** @var string */
|
||||
protected $phpbb_root_path = null;
|
||||
|
||||
/** @var string */
|
||||
protected $php_ext = null;
|
||||
|
||||
public function __construct(dbal $db, phpbb_cache_driver_interface $cache, $user, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->cache = $cache;
|
||||
$this->user = $user;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Module Exists
|
||||
*
|
||||
@ -117,11 +141,15 @@ class phpbb_db_migration_tools_module extends phpbb_db_migration_tools_base
|
||||
|
||||
if (!isset($data['module_langname']))
|
||||
{
|
||||
/**
|
||||
* @TODO does not work with 3.1 modules yet, but must continue for old 3.0 versions for
|
||||
* upgrades from a 3.0.x version to 3.1
|
||||
*/
|
||||
// The "automatic" way
|
||||
$basename = (isset($data['module_basename'])) ? $data['module_basename'] : '';
|
||||
$basename = str_replace(array('/', '\\'), '', $basename);
|
||||
$class = str_replace(array('/', '\\'), '', $class);
|
||||
$info_file = "$class/info/{$class}_$basename.$this->phpEx";
|
||||
$info_file = "$class/info/{$class}_$basename.{$this->php_ext}";
|
||||
|
||||
// The manual and automatic ways both failed...
|
||||
if (!file_exists((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file))
|
||||
@ -196,7 +224,7 @@ class phpbb_db_migration_tools_module extends phpbb_db_migration_tools_base
|
||||
|
||||
if (!class_exists('acp_modules'))
|
||||
{
|
||||
include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->phpEx);
|
||||
include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
|
||||
$this->user->add_lang('acp/modules');
|
||||
}
|
||||
$acp_modules = new acp_modules();
|
||||
@ -302,7 +330,7 @@ class phpbb_db_migration_tools_module extends phpbb_db_migration_tools_base
|
||||
// Automatic method
|
||||
$basename = str_replace(array('/', '\\'), '', $module['module_basename']);
|
||||
$class = str_replace(array('/', '\\'), '', $class);
|
||||
$info_file = "$class/info/{$class}_$basename.$this->phpEx";
|
||||
$info_file = "$class/info/{$class}_$basename.{$this->php_ext}";
|
||||
|
||||
if (!file_exists((($include_path === false) ? $this->phpbb_root_path . 'includes/' : $include_path) . $info_file))
|
||||
{
|
||||
@ -396,7 +424,7 @@ class phpbb_db_migration_tools_module extends phpbb_db_migration_tools_base
|
||||
|
||||
if (!class_exists('acp_modules'))
|
||||
{
|
||||
include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->phpEx);
|
||||
include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
|
||||
$this->user->add_lang('acp/modules');
|
||||
}
|
||||
$acp_modules = new acp_modules();
|
||||
|
@ -9,6 +9,30 @@
|
||||
|
||||
class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base
|
||||
{
|
||||
/** @var phpbb_auth */
|
||||
protected $auth = null;
|
||||
|
||||
/** @var phpbb_cache_service */
|
||||
protected $cache = null;
|
||||
|
||||
/** @var dbal */
|
||||
protected $db = null;
|
||||
|
||||
/** @var string */
|
||||
protected $phpbb_root_path = null;
|
||||
|
||||
/** @var string */
|
||||
protected $php_ext = null;
|
||||
|
||||
public function __construct(dbal $db, phpbb_cache_driver_interface $cache, phpbb_auth $auth, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->cache = $cache;
|
||||
$this->auth = $auth;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission Exists
|
||||
*
|
||||
@ -69,7 +93,7 @@ class phpbb_db_migration_tools_permission extends phpbb_db_migration_tools_base
|
||||
|
||||
if (!class_exists('auth_admin'))
|
||||
{
|
||||
include($this->phpbb_root_path . 'includes/acp/auth.' . $this->phpEx);
|
||||
include($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext);
|
||||
}
|
||||
$auth_admin = new auth_admin();
|
||||
|
||||
|
@ -22,6 +22,7 @@ if (!defined('IN_PHPBB'))
|
||||
*/
|
||||
class phpbb_db_migrator
|
||||
{
|
||||
protected $container;
|
||||
protected $db;
|
||||
protected $db_tools;
|
||||
protected $table_prefix;
|
||||
@ -37,24 +38,26 @@ class phpbb_db_migrator
|
||||
/**
|
||||
* Constructor of the database migrator
|
||||
*
|
||||
* @param dbal $db Connected database abstraction instance
|
||||
* @param phpbb_db_tools $db_tools Instance of db schema manipulation tools
|
||||
* @param string $table_prefix The prefix for all table names
|
||||
* @param string $migrations_table The name of the db table storing
|
||||
* information on applied migrations
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $php_ext
|
||||
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container Container supplying dependencies
|
||||
*/
|
||||
public function phpbb_db_migrator($db, $db_tools, $table_prefix, $migrations_table, $phpbb_root_path, $php_ext)
|
||||
public function phpbb_db_migrator(\Symfony\Component\DependencyInjection\ContainerInterface $container, $migrations)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->db_tools = $db_tools;
|
||||
$this->table_prefix = $table_prefix;
|
||||
$this->migrations_table = $migrations_table;
|
||||
$this->migrations = array();
|
||||
$this->container = $container;
|
||||
$this->db = $this->container->get('dbal.conn');
|
||||
$this->db_tools = $this->container->get('dbal.tools');
|
||||
$this->table_prefix = $this->container->getParameters('core.table_prefix');
|
||||
$this->migrations_table = $this->container->getParameters('tables.migrations');
|
||||
$this->migrations = $migrations;
|
||||
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->phpbb_root_path = $this->container->getParameters('core.root_path');
|
||||
$this->php_ext = $this->container->getParameters('core.php_ext');
|
||||
|
||||
/** @todo replace with collection_pass when merged */
|
||||
$this->tools = array(
|
||||
'config' => new phpbb_db_migration_tools_config,
|
||||
'module' => new phpbb_db_migration_tools_module,
|
||||
'permission' => new phpbb_db_migration_tools_permission,
|
||||
);
|
||||
|
||||
$this->load_migration_state();
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user