[ticket/15950] Add SQL transactions to mcp_main.php

PHPBB3-15950

And simultaneously remove a duplicated UPDATE query.
This commit is contained in:
3D-I 2019-01-22 16:10:52 +01:00
parent 871875d9aa
commit ca4a98a2de

View file

@ -414,6 +414,8 @@ function change_topic_type($action, $topic_ids)
if (confirm_box(true)) if (confirm_box(true))
{ {
$db->sql_transaction('begin');
$sql = 'UPDATE ' . TOPICS_TABLE . " $sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_type = $new_topic_type SET topic_type = $new_topic_type
WHERE " . $db->sql_in_set('topic_id', $topic_ids); WHERE " . $db->sql_in_set('topic_id', $topic_ids);
@ -425,13 +427,10 @@ function change_topic_type($action, $topic_ids)
$sql = 'DELETE FROM ' . TOPICS_TABLE . ' $sql = 'DELETE FROM ' . TOPICS_TABLE . '
WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids); WHERE ' . $db->sql_in_set('topic_moved_id', $topic_ids);
$db->sql_query($sql); $db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_type = $new_topic_type
WHERE " . $db->sql_in_set('topic_id', $topic_ids);
$db->sql_query($sql);
} }
$db->sql_transaction('commit');
$success_msg = (count($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED'; $success_msg = (count($topic_ids) == 1) ? 'TOPIC_TYPE_CHANGED' : 'TOPICS_TYPE_CHANGED';
if (count($topic_ids)) if (count($topic_ids))