Author: Kellanved
Date: Fri Aug 7 14:02:14 2009
New Revision: 9937
Log:
add transactions to sync(); not one big one to avoid nesting.
Modified:
branches/phpBB-3_0_0/phpBB/includes/functions_admin.php
Modified: branches/phpBB-3_0_0/phpBB/includes/functions_admin.php
==============================================================================
*** branches/phpBB-3_0_0/phpBB/includes/functions_admin.php (original)
--- branches/phpBB-3_0_0/phpBB/includes/functions_admin.php Fri Aug 7 14:02:14 2009
***************
*** 1330,1335 ****
--- 1330,1336 ----
switch ($mode)
{
case 'topic_moved':
+ $db->sql_transaction('begin');
switch ($db->sql_layer)
{
case 'mysql4':
***************
*** 1363,1374 ****
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_id_ary);
$db->sql_query($sql);
!
break;
}
! break;
case 'topic_approved':
switch ($db->sql_layer)
{
case 'mysql4':
--- 1364,1379 ----
$sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_id', $topic_id_ary);
$db->sql_query($sql);
!
break;
}
!
! $db->sql_transaction('commit');
! break;
case 'topic_approved':
+
+ $db->sql_transaction('begin');
switch ($db->sql_layer)
{
case 'mysql4':
***************
*** 1404,1414 ****
$db->sql_query($sql);
break;
}
! break;
case 'post_reported':
$post_ids = $post_reported = array();
!
$sql = 'SELECT p.post_id, p.post_reported
FROM ' . POSTS_TABLE . " p
$where_sql
--- 1409,1423 ----
$db->sql_query($sql);
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,1465 ****
WHERE ' . $db->sql_in_set('post_id', $post_ids);
$db->sql_query($sql);
}
! break;
case 'topic_reported':
if ($sync_extra)
--- 1468,1476 ----
WHERE ' . $db->sql_in_set('post_id', $post_ids);
$db->sql_query($sql);
}
!
! $db->sql_transaction('commit');
! break;
case 'topic_reported':
if ($sync_extra)
***************
*** 1469,1474 ****
--- 1480,1487 ----
$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,1511 ****
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
$db->sql_query($sql);
}
! break;
case 'post_attachment':
$post_ids = $post_attachment = array();
$sql = 'SELECT p.post_id, p.post_attachment
FROM ' . POSTS_TABLE . " p
$where_sql
--- 1514,1528 ----
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
$db->sql_query($sql);
}
!
! $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,1562 ****
WHERE ' . $db->sql_in_set('post_id', $post_ids);
$db->sql_query($sql);
}
! break;
case 'topic_attachment':
if ($sync_extra)
--- 1573,1581 ----
WHERE ' . $db->sql_in_set('post_id', $post_ids);
$db->sql_query($sql);
}
!
! $db->sql_transaction('commit');
! break;
case 'topic_attachment':
if ($sync_extra)
***************
*** 1566,1571 ****
--- 1585,1592 ----
$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,1607 ****
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
$db->sql_query($sql);
}
! break;
case 'forum':
// 1: Get the list of all forums
$sql = 'SELECT f.*
FROM ' . FORUMS_TABLE . " f
--- 1619,1633 ----
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
$db->sql_query($sql);
}
!
! $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,1812 ****
$db->sql_query($sql);
}
}
! break;
case 'topic':
$topic_data = $post_ids = $approved_unapproved_ids = $resync_forums = $delete_topics = $delete_posts = $moved_topics = array();
$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";
--- 1828,1842 ----
$db->sql_query($sql);
}
}
!
! $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,2134 ****
--- 2159,2166 ----
}
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,2142 ****
{
sync('forum', 'forum_id', array_values($resync_forums), true, true);
}
! break;
}
return;
--- 2168,2174 ----
{
sync('forum', 'forum_id', array_values($resync_forums), true, true);
}
! break;
}
return;
|