diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php index 896cd51fa3..03ab523d7c 100644 --- a/phpBB/includes/acp/acp_language.php +++ b/phpBB/includes/acp/acp_language.php @@ -886,7 +886,7 @@ class acp_language $radio_buttons = ''; foreach ($methods as $method) { - $radio_buttons .= ' ' . $method . ' '; + $radio_buttons .= ''; } $template->assign_vars(array( diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index ed49b6df06..12b1507b01 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -2151,7 +2151,7 @@ parse_css_file = {PARSE_CSS_FILE} $format_buttons = ''; foreach ($methods as $method) { - $format_buttons .= ' ' . $method . ' '; + $format_buttons .= ''; } $template->assign_vars(array( diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 13e21bd86b..0a09926156 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1080,12 +1080,12 @@ class acp_users { $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); $db->sql_query($sql); - $db->return_on_error = false; + $db->sql_return_on_error(false); } } diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index cfd13fd118..0001073319 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -38,6 +38,9 @@ class dbal // Holding the last sql query on sql error var $sql_error_sql = ''; + // Holding transaction count + var $transactions = 0; + // Supports multi inserts? var $multi_insert = false; @@ -197,29 +200,46 @@ class dbal switch ($status) { 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) { - $this->_sql_transaction('commit'); + $this->transactions++; + return true; } $result = $this->_sql_transaction('begin'); + + if (!$result) + { + $this->sql_error(); + } + $this->transaction = true; break; 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'); - $this->transaction = false; if (!$result) { - $this->_sql_transaction('rollback'); + $this->sql_error(); } + + $this->transaction = false; + $this->transactions = 0; break; case 'rollback': $result = $this->_sql_transaction('rollback'); $this->transaction = false; + $this->transactions = 0; break; default: diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 8613c10651..f67384b80e 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -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... 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')) { 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 ($topic_type != POST_GLOBAL) @@ -1924,8 +1922,6 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // 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']); 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']); } - $db->sql_transaction('commit'); - // Delete draft if post was loaded... $draft_id = request_var('draft_loaded', 0); 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') { // Mark this topic as posted to diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 5ff4324904..7f2e3e4c12 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1356,6 +1356,8 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) } } + $db->sql_transaction('begin'); + $sql = ''; switch ($mode) @@ -1432,8 +1434,6 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) if ($mode != 'edit') { - $db->sql_transaction('begin'); - if ($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)) ); } - - $db->sql_transaction('commit'); } // 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_transaction('begin'); - // Submit Attachments 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... $draft_id = request_var('draft_loaded', 0); if ($draft_id) @@ -1580,6 +1574,8 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) $db->sql_query($sql); } + $db->sql_transaction('commit'); + // Send Notifications if ($mode != 'edit') { diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index dd07fedf24..cb661ba5d5 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -702,9 +702,9 @@ function mcp_move_topic($topic_ids) $db->sql_query($sql); } - sync('forum', 'forum_id', array($forum_id, $to_forum_id)); - $db->sql_transaction('commit'); + + sync('forum', 'forum_id', array($forum_id, $to_forum_id)); } else { diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 0af987efab..50bf7bcb2a 100755 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -1128,9 +1128,9 @@ class fulltext_native extends search_backend { $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->return_on_error = false; + $db->sql_return_on_error(false); } 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) { $title_match = ($word_in == 'title') ? 1 : 0; @@ -1187,7 +1187,7 @@ class fulltext_native extends search_backend $db->sql_query($sql); } } - $db->return_on_error = false; + $db->sql_return_on_error(false); $db->sql_transaction('commit'); diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index cea9a43ffd..e8c4804e5a 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -343,12 +343,12 @@ class ucp_profile { $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); $db->sql_query($sql); - $db->return_on_error = false; + $db->sql_return_on_error(false); } } diff --git a/phpBB/install/convertors/functions_phpbb20.php b/phpBB/install/convertors/functions_phpbb20.php index 85960bfb70..7f51b90787 100644 --- a/phpBB/install/convertors/functions_phpbb20.php +++ b/phpBB/install/convertors/functions_phpbb20.php @@ -1714,10 +1714,10 @@ function phpbb_check_username_collisions() break; } - $db->return_on_error = true; + $db->sql_return_on_error(true); $db->sql_query($drop_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!) $sql = 'SELECT user_id, username diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 55180ec80d..2b54a2b1aa 100755 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -1095,7 +1095,7 @@ class install_install extends module $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); // 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 ($dbms == 'mysql') @@ -1380,7 +1380,7 @@ class install_install extends module $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); // 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/acp/acp_modules.' . $phpEx);