mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[feature/migrations] 3.0.8-rc1 migration, fix some calls
PHPBB3-9737
This commit is contained in:
parent
b999a75528
commit
e7389e4c32
3 changed files with 93 additions and 90 deletions
|
@ -47,7 +47,7 @@ class phpbb_db_migration_v3011rc1 extends phpbb_db_migration
|
|||
$sql = 'UPDATE ' . USERS_TABLE . '
|
||||
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);
|
||||
$this->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ class phpbb_db_migration_v3011rc1 extends phpbb_db_migration
|
|||
{
|
||||
$sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
|
||||
WHERE ' . $this->db->sql_in_set('msg_id', $delete_pms);
|
||||
$this->sql_query($sql, $errored, $error_ary);
|
||||
$this->sql_query($sql);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -20,14 +20,37 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration
|
|||
}
|
||||
|
||||
function update_data()
|
||||
{
|
||||
return array(
|
||||
array('custom', array(array(&$this, 'update_file_extension_group_names'))),
|
||||
array('custom', array(array(&$this, 'update_module_auth'))),
|
||||
array('custom', array(array(&$this, 'update_bots'))),
|
||||
array('custom', array(array(&$this, 'delete_orphan_shadow_topics'))),
|
||||
array('module.add', array(
|
||||
'post' => array(
|
||||
'base' => 'board',
|
||||
'class' => 'acp',
|
||||
'title' => 'ACP_POST_SETTINGS',
|
||||
'auth' => 'acl_a_board',
|
||||
'cat' => 'ACP_MESSAGES',
|
||||
'after' => array('message', 'ACP_MESSAGE_SETTINGS')
|
||||
),
|
||||
)),
|
||||
array('config.add', array('load_unreads_search', 1)),
|
||||
array('config.update_if', array(600, 'queue_interval', 60)),
|
||||
array('config.update_if', array(50, 'email_package_size', 20)),
|
||||
);
|
||||
}
|
||||
|
||||
function update_file_extension_group_names()
|
||||
{
|
||||
// Update file extension group names to use language strings.
|
||||
$sql = 'SELECT lang_dir
|
||||
FROM ' . LANG_TABLE;
|
||||
$result = $db->sql_query($sql);
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
$extension_groups_updated = array();
|
||||
while ($lang_dir = $db->sql_fetchfield('lang_dir'))
|
||||
while ($lang_dir = $this->db->sql_fetchfield('lang_dir'))
|
||||
{
|
||||
$lang_dir = basename($lang_dir);
|
||||
|
||||
|
@ -37,9 +60,9 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration
|
|||
// On an already updated board, they can also already be in language/.../acp/attachments.php
|
||||
// in the board root.
|
||||
$lang_files = array(
|
||||
"{$phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.$phpEx",
|
||||
"{$phpbb_root_path}language/$lang_dir/install.$phpEx",
|
||||
"{$phpbb_root_path}language/$lang_dir/acp/attachments.$phpEx",
|
||||
"{$this->phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.$this->phpEx",
|
||||
"{$this->phpbb_root_path}language/$lang_dir/install.$this->phpEx",
|
||||
"{$this->phpbb_root_path}language/$lang_dir/acp/attachments.$this->phpEx",
|
||||
);
|
||||
|
||||
foreach ($lang_files as $lang_file)
|
||||
|
@ -64,48 +87,38 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration
|
|||
);
|
||||
|
||||
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . '
|
||||
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
|
||||
WHERE group_name = '" . $db->sql_escape($lang_val) . "'";
|
||||
_sql($sql, $errored, $error_ary);
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . "
|
||||
WHERE group_name = '" . $this->db->sql_escape($lang_val) . "'";
|
||||
$this->sql_query($sql);
|
||||
|
||||
$extension_groups_updated[$lang_key] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
// Install modules
|
||||
$modules_to_install = array(
|
||||
'post' => array(
|
||||
'base' => 'board',
|
||||
'class' => 'acp',
|
||||
'title' => 'ACP_POST_SETTINGS',
|
||||
'auth' => 'acl_a_board',
|
||||
'cat' => 'ACP_MESSAGES',
|
||||
'after' => array('message', 'ACP_MESSAGE_SETTINGS')
|
||||
),
|
||||
);
|
||||
|
||||
_add_modules($modules_to_install);
|
||||
|
||||
// update
|
||||
function update_module_auth()
|
||||
{
|
||||
$sql = 'UPDATE ' . MODULES_TABLE . '
|
||||
SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\'
|
||||
WHERE module_class = \'ucp\'
|
||||
AND module_basename = \'profile\'
|
||||
AND module_mode = \'avatar\'';
|
||||
_sql($sql, $errored, $error_ary);
|
||||
$this->sql_query($sql);
|
||||
}
|
||||
|
||||
// add Bing Bot
|
||||
function update_bots()
|
||||
{
|
||||
$bot_name = 'Bing [Bot]';
|
||||
$bot_name_clean = utf8_clean_string($bot_name);
|
||||
|
||||
$sql = 'SELECT user_id
|
||||
FROM ' . USERS_TABLE . "
|
||||
WHERE username_clean = '" . $db->sql_escape($bot_name_clean) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
$bing_already_added = (bool) $db->sql_fetchfield('user_id');
|
||||
$db->sql_freeresult($result);
|
||||
WHERE username_clean = '" . $this->db->sql_escape($bot_name_clean) . "'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$bing_already_added = (bool) $this->db->sql_fetchfield('user_id');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if (!$bing_already_added)
|
||||
{
|
||||
|
@ -114,9 +127,9 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration
|
|||
$sql = 'SELECT group_id, group_colour
|
||||
FROM ' . GROUPS_TABLE . "
|
||||
WHERE group_name = 'BOTS'";
|
||||
$result = $db->sql_query($sql);
|
||||
$group_row = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
$result = $this->db->sql_query($sql);
|
||||
$group_row = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if (!$group_row)
|
||||
{
|
||||
|
@ -127,7 +140,7 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration
|
|||
|
||||
if (!function_exists('user_add'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
|
||||
include($this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx);
|
||||
}
|
||||
|
||||
$user_row = array(
|
||||
|
@ -138,16 +151,16 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration
|
|||
'user_password' => '',
|
||||
'user_colour' => $group_row['group_colour'],
|
||||
'user_email' => '',
|
||||
'user_lang' => $config['default_lang'],
|
||||
'user_style' => $config['default_style'],
|
||||
'user_lang' => $this->config['default_lang'],
|
||||
'user_style' => $this->config['default_style'],
|
||||
'user_timezone' => 0,
|
||||
'user_dateformat' => $config['default_dateformat'],
|
||||
'user_dateformat' => $this->config['default_dateformat'],
|
||||
'user_allow_massemail' => 0,
|
||||
);
|
||||
|
||||
$user_id = user_add($user_row);
|
||||
|
||||
$sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
|
||||
$sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
|
||||
'bot_active' => 1,
|
||||
'bot_name' => (string) $bot_name,
|
||||
'user_id' => (int) $user_id,
|
||||
|
@ -155,68 +168,58 @@ class phpbb_db_migration_v308rc1 extends phpbb_db_migration
|
|||
'bot_ip' => (string) $bot_ip,
|
||||
));
|
||||
|
||||
_sql($sql, $errored, $error_ary);
|
||||
$this->sql_query($sql);
|
||||
}
|
||||
// end Bing Bot addition
|
||||
}
|
||||
|
||||
function delete_orphan_shadow_topics()
|
||||
{
|
||||
// Delete shadow topics pointing to not existing topics
|
||||
$batch_size = 500;
|
||||
|
||||
// Set of affected forums we have to resync
|
||||
$sync_forum_ids = array();
|
||||
|
||||
do
|
||||
{
|
||||
$sql_array = array(
|
||||
'SELECT' => 't1.topic_id, t1.forum_id',
|
||||
'FROM' => array(
|
||||
TOPICS_TABLE => 't1',
|
||||
$sql_array = array(
|
||||
'SELECT' => 't1.topic_id, t1.forum_id',
|
||||
'FROM' => array(
|
||||
TOPICS_TABLE => 't1',
|
||||
),
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(TOPICS_TABLE => 't2'),
|
||||
'ON' => 't1.topic_moved_id = t2.topic_id',
|
||||
),
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(TOPICS_TABLE => 't2'),
|
||||
'ON' => 't1.topic_moved_id = t2.topic_id',
|
||||
),
|
||||
),
|
||||
'WHERE' => 't1.topic_moved_id <> 0
|
||||
AND t2.topic_id IS NULL',
|
||||
);
|
||||
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||
$result = $db->sql_query_limit($sql, $batch_size);
|
||||
),
|
||||
'WHERE' => 't1.topic_moved_id <> 0
|
||||
AND t2.topic_id IS NULL',
|
||||
);
|
||||
$sql = $this->db->sql_build_query('SELECT', $sql_array);
|
||||
$result = $this->db->sql_query_limit($sql, $batch_size);
|
||||
|
||||
$topic_ids = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$topic_ids[] = (int) $row['topic_id'];
|
||||
|
||||
$sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id'];
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (!empty($topic_ids))
|
||||
{
|
||||
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
while (sizeof($topic_ids) == $batch_size);
|
||||
|
||||
// Sync the forums we have deleted shadow topics from.
|
||||
sync('forum', 'forum_id', $sync_forum_ids, true, true);
|
||||
|
||||
// Unread posts search load switch
|
||||
set_config('load_unreads_search', '1');
|
||||
|
||||
// Reduce queue interval to 60 seconds, email package size to 20
|
||||
if ($config['queue_interval'] == 600)
|
||||
$topic_ids = array();
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
set_config('queue_interval', '60');
|
||||
}
|
||||
$topic_ids[] = (int) $row['topic_id'];
|
||||
|
||||
if ($config['email_package_size'] == 50)
|
||||
$sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id'];
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if (!empty($topic_ids))
|
||||
{
|
||||
set_config('email_package_size', '20');
|
||||
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
|
||||
WHERE ' . $this->db->sql_in_set('topic_id', $topic_ids);
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
// Sync the forums we have deleted shadow topics from.
|
||||
sync('forum', 'forum_id', $sync_forum_ids, true, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ class phpbb_db_migration_v309rc1 extends phpbb_db_migration
|
|||
$sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . '
|
||||
SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
|
||||
WHERE group_id = ' . $row['group_id'];
|
||||
$this->sql_query($sql, $errored, $error_ary);
|
||||
$this->sql_query($sql);
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue