mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-06 07:35:29 +02:00
add transactions to sync(); not one big one to avoid nesting.
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9937 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
090ab9bf05
commit
d2c818ffb9
@ -1330,6 +1330,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||
switch ($mode)
|
||||
{
|
||||
case 'topic_moved':
|
||||
$db->sql_transaction('begin');
|
||||
switch ($db->sql_layer)
|
||||
{
|
||||
case 'mysql4':
|
||||
@ -1363,12 +1364,16 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('topic_id', $topic_id_ary);
|
||||
$db->sql_query($sql);
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
break;
|
||||
|
||||
case 'topic_approved':
|
||||
|
||||
$db->sql_transaction('begin');
|
||||
switch ($db->sql_layer)
|
||||
{
|
||||
case 'mysql4':
|
||||
@ -1404,11 +1409,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||
$db->sql_query($sql);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
break;
|
||||
|
||||
case 'post_reported':
|
||||
$post_ids = $post_reported = array();
|
||||
|
||||
|
||||
$db->sql_transaction('begin');
|
||||
|
||||
$sql = 'SELECT p.post_id, p.post_reported
|
||||
FROM ' . POSTS_TABLE . " p
|
||||
$where_sql
|
||||
@ -1459,7 +1468,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||
WHERE ' . $db->sql_in_set('post_id', $post_ids);
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
break;
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
break;
|
||||
|
||||
case 'topic_reported':
|
||||
if ($sync_extra)
|
||||
@ -1469,6 +1480,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||
|
||||
$topic_ids = $topic_reported = array();
|
||||
|
||||
$db->sql_transaction('begin');
|
||||
|
||||
$sql = 'SELECT DISTINCT(t.topic_id)
|
||||
FROM ' . POSTS_TABLE . " t
|
||||
$where_sql_and t.post_reported = 1";
|
||||
@ -1501,11 +1514,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
break;
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
break;
|
||||
|
||||
case 'post_attachment':
|
||||
$post_ids = $post_attachment = array();
|
||||
|
||||
$db->sql_transaction('begin');
|
||||
|
||||
$sql = 'SELECT p.post_id, p.post_attachment
|
||||
FROM ' . POSTS_TABLE . " p
|
||||
$where_sql
|
||||
@ -1556,7 +1573,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||
WHERE ' . $db->sql_in_set('post_id', $post_ids);
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
break;
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
break;
|
||||
|
||||
case 'topic_attachment':
|
||||
if ($sync_extra)
|
||||
@ -1566,6 +1585,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||
|
||||
$topic_ids = $topic_attachment = array();
|
||||
|
||||
$db->sql_transaction('begin');
|
||||
|
||||
$sql = 'SELECT DISTINCT(t.topic_id)
|
||||
FROM ' . POSTS_TABLE . " t
|
||||
$where_sql_and t.post_attachment = 1";
|
||||
@ -1598,10 +1619,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
break;
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
|
||||
break;
|
||||
|
||||
case 'forum':
|
||||
|
||||
$db->sql_transaction('begin');
|
||||
|
||||
// 1: Get the list of all forums
|
||||
$sql = 'SELECT f.*
|
||||
FROM ' . FORUMS_TABLE . " f
|
||||
@ -1802,11 +1828,15 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
break;
|
||||
|
||||
case 'topic':
|
||||
$topic_data = $post_ids = $approved_unapproved_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array();
|
||||
|
||||
$db->sql_transaction('begin');
|
||||
|
||||
$sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_approved, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time
|
||||
FROM ' . TOPICS_TABLE . " t
|
||||
$where_sql";
|
||||
@ -2129,6 +2159,8 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||
}
|
||||
unset($topic_data);
|
||||
|
||||
$db->sql_transaction('commit');
|
||||
|
||||
// if some topics have been resync'ed then resync parent forums
|
||||
// except when we're only syncing a range, we don't want to sync forums during
|
||||
// batch processing.
|
||||
@ -2136,7 +2168,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
|
||||
{
|
||||
sync('forum', 'forum_id', array_values($resync_forums), true, true);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user