mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/migrations] Some migrations data
PHPBB3-9737
This commit is contained in:
parent
b1f9ca2f65
commit
b999a75528
3 changed files with 65 additions and 45 deletions
|
@ -21,9 +21,8 @@ class phpbb_db_migration_v3010rc1 extends phpbb_db_migration
|
|||
|
||||
function update_data()
|
||||
{
|
||||
if (!isset($config['email_max_chunk_size']))
|
||||
{
|
||||
set_config('email_max_chunk_size', '50');
|
||||
}
|
||||
return array(
|
||||
array('config.add', array('email_max_chunk_size', 50)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,28 +20,39 @@ class phpbb_db_migration_v3011rc1 extends phpbb_db_migration
|
|||
}
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array(&$this, 'cleanup_deactivated_styles'))),
|
||||
array('custom', array(array(&$this, 'delete_orphan_private_messages'))),
|
||||
);
|
||||
}
|
||||
|
||||
function cleanup_deactivated_styles()
|
||||
{
|
||||
// Updates users having current style a deactivated one
|
||||
$sql = 'SELECT style_id
|
||||
FROM ' . STYLES_TABLE . '
|
||||
WHERE style_active = 0';
|
||||
$result = $db->sql_query($sql);
|
||||
$result = $this->sql_query($sql);
|
||||
|
||||
$deactivated_style_ids = array();
|
||||
while ($style_id = $db->sql_fetchfield('style_id', false, $result))
|
||||
while ($style_id = $this->db->sql_fetchfield('style_id', false, $result))
|
||||
{
|
||||
$deactivated_style_ids[] = (int) $style_id;
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if (!empty($deactivated_style_ids))
|
||||
{
|
||||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
SET user_style = ' . (int) $config['default_style'] .'
|
||||
WHERE ' . $db->sql_in_set('user_style', $deactivated_style_ids);
|
||||
_sql($sql, $errored, $error_ary);
|
||||
SET user_style = ' . (int) $this->config['default_style'] .'
|
||||
WHERE ' . $this->db->sql_in_set('user_style', $deactivated_style_ids);
|
||||
$this->sql_query($sql, $errored, $error_ary);
|
||||
}
|
||||
}
|
||||
|
||||
function delete_orphan_private_messages()
|
||||
{
|
||||
// Delete orphan private messages
|
||||
$batch_size = 500;
|
||||
|
||||
|
@ -58,14 +69,12 @@ class phpbb_db_migration_v3011rc1 extends phpbb_db_migration
|
|||
),
|
||||
'WHERE' => 't.user_id IS NULL',
|
||||
);
|
||||
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||
$sql = $this->db->sql_build_query('SELECT', $sql_array);
|
||||
|
||||
do
|
||||
{
|
||||
$result = $db->sql_query_limit($sql, $batch_size);
|
||||
$result = $this->db->sql_query_limit($sql, $batch_size);
|
||||
|
||||
$delete_pms = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$delete_pms[] = (int) $row['msg_id'];
|
||||
}
|
||||
|
@ -74,10 +83,14 @@ class phpbb_db_migration_v3011rc1 extends phpbb_db_migration
|
|||
if (!empty($delete_pms))
|
||||
{
|
||||
$sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('msg_id', $delete_pms);
|
||||
_sql($sql, $errored, $error_ary);
|
||||
WHERE ' . $this->db->sql_in_set('msg_id', $delete_pms);
|
||||
$this->sql_query($sql, $errored, $error_ary);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
while (sizeof($delete_pms) == $batch_size);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,46 +53,54 @@ class phpbb_db_migration_v309rc1 extends phpbb_db_migration
|
|||
|
||||
function update_data()
|
||||
{
|
||||
set_config('ip_login_limit_max', '50');
|
||||
set_config('ip_login_limit_time', '21600');
|
||||
set_config('ip_login_limit_use_forwarded', '0');
|
||||
return array(
|
||||
array('config.add', array('ip_login_limit_max', 50)),
|
||||
array('config.add', array('ip_login_limit_time', 21600)),
|
||||
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'))),
|
||||
);
|
||||
}
|
||||
|
||||
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 ' . $db->sql_like_expression('EXT_GROUP_' . $db->any_char);
|
||||
$result = $db->sql_query($sql);
|
||||
WHERE group_name ' . $this->db->sql_like_expression('EXT_GROUP_' . $this->db->any_char);
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$sql_ary = array(
|
||||
'group_name' => substr($row['group_name'], 10), // Strip off 'EXT_GROUP_'
|
||||
);
|
||||
|
||||
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
|
||||
WHERE group_id = ' . $row['group_id'];
|
||||
_sql($sql, $errored, $error_ary);
|
||||
$this->sql_query($sql, $errored, $error_ary);
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
global $db_tools, $table_prefix;
|
||||
|
||||
function fix_firebird_qa_captcha()
|
||||
{
|
||||
// Recover from potentially broken Q&A CAPTCHA table on firebird
|
||||
// Q&A CAPTCHA was uninstallable, so it's safe to remove these
|
||||
// without data loss
|
||||
if ($db_tools->sql_layer == 'firebird')
|
||||
if ($this->db_tools->sql_layer == 'firebird')
|
||||
{
|
||||
$tables = array(
|
||||
$table_prefix . 'captcha_questions',
|
||||
$table_prefix . 'captcha_answers',
|
||||
$table_prefix . 'qa_confirm',
|
||||
$this->table_prefix . 'captcha_questions',
|
||||
$this->table_prefix . 'captcha_answers',
|
||||
$this->table_prefix . 'qa_confirm',
|
||||
);
|
||||
foreach ($tables as $table)
|
||||
{
|
||||
if ($db_tools->sql_table_exists($table))
|
||||
if ($this->db_tools->sql_table_exists($table))
|
||||
{
|
||||
$db_tools->sql_table_drop($table);
|
||||
$this->db_tools->sql_table_drop($table);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue