mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 05:38:52 +00:00
Better support for nested transactions...
git-svn-id: file:///svn/phpbb/trunk@7469 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
eee1dedc13
commit
a5704a0b01
11 changed files with 48 additions and 36 deletions
|
@ -886,7 +886,7 @@ class acp_language
|
||||||
$radio_buttons = '';
|
$radio_buttons = '';
|
||||||
foreach ($methods as $method)
|
foreach ($methods as $method)
|
||||||
{
|
{
|
||||||
$radio_buttons .= '<input type="radio"' . ((!$radio_buttons) ? ' id="use_method"' : '') . ' class="radio" value="' . $method . '" name="use_method" /> ' . $method . ' ';
|
$radio_buttons .= '<label><input type="radio"' . ((!$radio_buttons) ? ' id="use_method"' : '') . ' class="radio" value="' . $method . '" name="use_method" /> ' . $method . '</label>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
|
|
|
@ -2151,7 +2151,7 @@ parse_css_file = {PARSE_CSS_FILE}
|
||||||
$format_buttons = '';
|
$format_buttons = '';
|
||||||
foreach ($methods as $method)
|
foreach ($methods as $method)
|
||||||
{
|
{
|
||||||
$format_buttons .= '<input type="radio"' . ((!$format_buttons) ? ' id="format"' : '') . ' class="radio" value="' . $method . '" name="format"' . (($method == $format) ? ' checked="checked"' : '') . ' /> ' . $method . ' ';
|
$format_buttons .= '<label><input type="radio"' . ((!$format_buttons) ? ' id="format"' : '') . ' class="radio" value="' . $method . '" name="format"' . (($method == $format) ? ' checked="checked"' : '') . ' /> ' . $method . '</label>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
|
|
|
@ -1080,12 +1080,12 @@ class acp_users
|
||||||
{
|
{
|
||||||
$cp_data['user_id'] = (int) $user_id;
|
$cp_data['user_id'] = (int) $user_id;
|
||||||
|
|
||||||
$db->return_on_error = true;
|
$db->sql_return_on_error(true);
|
||||||
|
|
||||||
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data);
|
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data);
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
||||||
$db->return_on_error = false;
|
$db->sql_return_on_error(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,9 @@ class dbal
|
||||||
// Holding the last sql query on sql error
|
// Holding the last sql query on sql error
|
||||||
var $sql_error_sql = '';
|
var $sql_error_sql = '';
|
||||||
|
|
||||||
|
// Holding transaction count
|
||||||
|
var $transactions = 0;
|
||||||
|
|
||||||
// Supports multi inserts?
|
// Supports multi inserts?
|
||||||
var $multi_insert = false;
|
var $multi_insert = false;
|
||||||
|
|
||||||
|
@ -197,29 +200,46 @@ class dbal
|
||||||
switch ($status)
|
switch ($status)
|
||||||
{
|
{
|
||||||
case 'begin':
|
case 'begin':
|
||||||
// Commit previously opened transaction before opening another transaction
|
// If we are within a transaction we will not open another one, but enclose the current one to not loose data (prevening auto commit)
|
||||||
if ($this->transaction)
|
if ($this->transaction)
|
||||||
{
|
{
|
||||||
$this->_sql_transaction('commit');
|
$this->transactions++;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->_sql_transaction('begin');
|
$result = $this->_sql_transaction('begin');
|
||||||
|
|
||||||
|
if (!$result)
|
||||||
|
{
|
||||||
|
$this->sql_error();
|
||||||
|
}
|
||||||
|
|
||||||
$this->transaction = true;
|
$this->transaction = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'commit':
|
case 'commit':
|
||||||
|
// If there was a previously opened transaction we do not commit yet... but count back the number of inner transactions
|
||||||
|
if ($this->transaction && $this->transactions)
|
||||||
|
{
|
||||||
|
$this->transactions--;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$result = $this->_sql_transaction('commit');
|
$result = $this->_sql_transaction('commit');
|
||||||
$this->transaction = false;
|
|
||||||
|
|
||||||
if (!$result)
|
if (!$result)
|
||||||
{
|
{
|
||||||
$this->_sql_transaction('rollback');
|
$this->sql_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->transaction = false;
|
||||||
|
$this->transactions = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'rollback':
|
case 'rollback':
|
||||||
$result = $this->_sql_transaction('rollback');
|
$result = $this->_sql_transaction('rollback');
|
||||||
$this->transaction = false;
|
$this->transaction = false;
|
||||||
|
$this->transactions = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1377,8 +1377,6 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->sql_transaction('commit');
|
|
||||||
|
|
||||||
// Adjust posted info for this user by looking for a post by him/her within this topic...
|
// Adjust posted info for this user by looking for a post by him/her within this topic...
|
||||||
if ($post_mode != 'delete_topic' && $config['load_db_track'] && $data['poster_id'] != ANONYMOUS)
|
if ($post_mode != 'delete_topic' && $config['load_db_track'] && $data['poster_id'] != ANONYMOUS)
|
||||||
{
|
{
|
||||||
|
@ -1400,6 +1398,8 @@ function delete_post($forum_id, $topic_id, $post_id, &$data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$db->sql_transaction('commit');
|
||||||
|
|
||||||
if ($data['post_reported'] && ($post_mode != 'delete_topic'))
|
if ($data['post_reported'] && ($post_mode != 'delete_topic'))
|
||||||
{
|
{
|
||||||
sync('topic_reported', 'topic_id', array($topic_id));
|
sync('topic_reported', 'topic_id', array($topic_id));
|
||||||
|
@ -1871,8 +1871,6 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->sql_transaction('commit');
|
|
||||||
|
|
||||||
if ($post_mode == 'post' || $post_mode == 'reply' || $post_mode == 'edit_last_post' || $post_mode == 'edit_topic')
|
if ($post_mode == 'post' || $post_mode == 'reply' || $post_mode == 'edit_last_post' || $post_mode == 'edit_topic')
|
||||||
{
|
{
|
||||||
if ($topic_type != POST_GLOBAL)
|
if ($topic_type != POST_GLOBAL)
|
||||||
|
@ -1924,8 +1922,6 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update forum stats
|
// Update forum stats
|
||||||
$db->sql_transaction('begin');
|
|
||||||
|
|
||||||
$where_sql = array(POSTS_TABLE => 'post_id = ' . $data['post_id'], TOPICS_TABLE => 'topic_id = ' . $data['topic_id'], FORUMS_TABLE => 'forum_id = ' . $data['forum_id'], USERS_TABLE => 'user_id = ' . $user->data['user_id']);
|
$where_sql = array(POSTS_TABLE => 'post_id = ' . $data['post_id'], TOPICS_TABLE => 'topic_id = ' . $data['topic_id'], FORUMS_TABLE => 'forum_id = ' . $data['forum_id'], USERS_TABLE => 'user_id = ' . $user->data['user_id']);
|
||||||
|
|
||||||
foreach ($sql_data as $table => $update_ary)
|
foreach ($sql_data as $table => $update_ary)
|
||||||
|
@ -1968,8 +1964,6 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||||
$search->index($mode, $data['post_id'], $data['message'], $subject, $poster_id, ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']);
|
$search->index($mode, $data['post_id'], $data['message'], $subject, $poster_id, ($topic_type == POST_GLOBAL) ? 0 : $data['forum_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->sql_transaction('commit');
|
|
||||||
|
|
||||||
// Delete draft if post was loaded...
|
// Delete draft if post was loaded...
|
||||||
$draft_id = request_var('draft_loaded', 0);
|
$draft_id = request_var('draft_loaded', 0);
|
||||||
if ($draft_id)
|
if ($draft_id)
|
||||||
|
@ -1998,6 +1992,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$db->sql_transaction('commit');
|
||||||
|
|
||||||
if ($mode == 'post' || $mode == 'reply' || $mode == 'quote')
|
if ($mode == 'post' || $mode == 'reply' || $mode == 'quote')
|
||||||
{
|
{
|
||||||
// Mark this topic as posted to
|
// Mark this topic as posted to
|
||||||
|
|
|
@ -1356,6 +1356,8 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$db->sql_transaction('begin');
|
||||||
|
|
||||||
$sql = '';
|
$sql = '';
|
||||||
|
|
||||||
switch ($mode)
|
switch ($mode)
|
||||||
|
@ -1432,8 +1434,6 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||||
|
|
||||||
if ($mode != 'edit')
|
if ($mode != 'edit')
|
||||||
{
|
{
|
||||||
$db->sql_transaction('begin');
|
|
||||||
|
|
||||||
if ($sql)
|
if ($sql)
|
||||||
{
|
{
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
@ -1474,8 +1474,6 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||||
'pm_forwarded' => ($mode == 'forward') ? 1 : 0))
|
'pm_forwarded' => ($mode == 'forward') ? 1 : 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->sql_transaction('commit');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set user last post time
|
// Set user last post time
|
||||||
|
@ -1487,8 +1485,6 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->sql_transaction('begin');
|
|
||||||
|
|
||||||
// Submit Attachments
|
// Submit Attachments
|
||||||
if (!empty($data['attachment_data']) && $data['msg_id'] && in_array($mode, array('post', 'reply', 'quote', 'quotepost', 'edit', 'forward')))
|
if (!empty($data['attachment_data']) && $data['msg_id'] && in_array($mode, array('post', 'reply', 'quote', 'quotepost', 'edit', 'forward')))
|
||||||
{
|
{
|
||||||
|
@ -1568,8 +1564,6 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->sql_transaction('commit');
|
|
||||||
|
|
||||||
// Delete draft if post was loaded...
|
// Delete draft if post was loaded...
|
||||||
$draft_id = request_var('draft_loaded', 0);
|
$draft_id = request_var('draft_loaded', 0);
|
||||||
if ($draft_id)
|
if ($draft_id)
|
||||||
|
@ -1580,6 +1574,8 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true)
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$db->sql_transaction('commit');
|
||||||
|
|
||||||
// Send Notifications
|
// Send Notifications
|
||||||
if ($mode != 'edit')
|
if ($mode != 'edit')
|
||||||
{
|
{
|
||||||
|
|
|
@ -702,9 +702,9 @@ function mcp_move_topic($topic_ids)
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
sync('forum', 'forum_id', array($forum_id, $to_forum_id));
|
|
||||||
|
|
||||||
$db->sql_transaction('commit');
|
$db->sql_transaction('commit');
|
||||||
|
|
||||||
|
sync('forum', 'forum_id', array($forum_id, $to_forum_id));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1128,9 +1128,9 @@ class fulltext_native extends search_backend
|
||||||
{
|
{
|
||||||
$sql_ary[] = array('word_text' => $word, 'word_count' => 0);
|
$sql_ary[] = array('word_text' => $word, 'word_count' => 0);
|
||||||
}
|
}
|
||||||
$db->return_on_error = true;
|
$db->sql_return_on_error(true);
|
||||||
$db->sql_multi_insert(SEARCH_WORDLIST_TABLE, $sql_ary);
|
$db->sql_multi_insert(SEARCH_WORDLIST_TABLE, $sql_ary);
|
||||||
$db->return_on_error = false;
|
$db->sql_return_on_error(false);
|
||||||
}
|
}
|
||||||
unset($new_words, $sql_ary);
|
unset($new_words, $sql_ary);
|
||||||
}
|
}
|
||||||
|
@ -1168,7 +1168,7 @@ class fulltext_native extends search_backend
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->return_on_error = true;
|
$db->sql_return_on_error(true);
|
||||||
foreach ($words['add'] as $word_in => $word_ary)
|
foreach ($words['add'] as $word_in => $word_ary)
|
||||||
{
|
{
|
||||||
$title_match = ($word_in == 'title') ? 1 : 0;
|
$title_match = ($word_in == 'title') ? 1 : 0;
|
||||||
|
@ -1187,7 +1187,7 @@ class fulltext_native extends search_backend
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->return_on_error = false;
|
$db->sql_return_on_error(false);
|
||||||
|
|
||||||
$db->sql_transaction('commit');
|
$db->sql_transaction('commit');
|
||||||
|
|
||||||
|
|
|
@ -343,12 +343,12 @@ class ucp_profile
|
||||||
{
|
{
|
||||||
$cp_data['user_id'] = (int) $user->data['user_id'];
|
$cp_data['user_id'] = (int) $user->data['user_id'];
|
||||||
|
|
||||||
$db->return_on_error = true;
|
$db->sql_return_on_error(true);
|
||||||
|
|
||||||
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data);
|
$sql = 'INSERT INTO ' . PROFILE_FIELDS_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $cp_data);
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
||||||
$db->return_on_error = false;
|
$db->sql_return_on_error(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1714,10 +1714,10 @@ function phpbb_check_username_collisions()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->return_on_error = true;
|
$db->sql_return_on_error(true);
|
||||||
$db->sql_query($drop_sql);
|
$db->sql_query($drop_sql);
|
||||||
$db->sql_query($create_sql);
|
$db->sql_query($create_sql);
|
||||||
$db->return_on_error = false;
|
$db->sql_return_on_error(false);
|
||||||
|
|
||||||
// now select all user_ids and usernames and then convert the username (this can take quite a while!)
|
// now select all user_ids and usernames and then convert the username (this can take quite a while!)
|
||||||
$sql = 'SELECT user_id, username
|
$sql = 'SELECT user_id, username
|
||||||
|
|
|
@ -1095,7 +1095,7 @@ class install_install extends module
|
||||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
|
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
|
||||||
|
|
||||||
// NOTE: trigger_error does not work here.
|
// NOTE: trigger_error does not work here.
|
||||||
$db->return_on_error = true;
|
$db->sql_return_on_error(true);
|
||||||
|
|
||||||
// If mysql is chosen, we need to adjust the schema filename slightly to reflect the correct version. ;)
|
// If mysql is chosen, we need to adjust the schema filename slightly to reflect the correct version. ;)
|
||||||
if ($dbms == 'mysql')
|
if ($dbms == 'mysql')
|
||||||
|
@ -1380,7 +1380,7 @@ class install_install extends module
|
||||||
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
|
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
|
||||||
|
|
||||||
// NOTE: trigger_error does not work here.
|
// NOTE: trigger_error does not work here.
|
||||||
$db->return_on_error = true;
|
$db->sql_return_on_error(true);
|
||||||
|
|
||||||
include_once($phpbb_root_path . 'includes/constants.' . $phpEx);
|
include_once($phpbb_root_path . 'includes/constants.' . $phpEx);
|
||||||
include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);
|
include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);
|
||||||
|
|
Loading…
Add table
Reference in a new issue