});
Bugzilla::Flag::validate($cgi, $bug->id, $attachment->id);
- # Lock database tables in preparation for updating the attachment.
- $dbh->bz_lock_tables('attachments WRITE', 'flags WRITE' ,
- 'flagtypes READ', 'fielddefs READ', 'bugs_activity WRITE',
- 'flaginclusions AS i READ', 'flagexclusions AS e READ',
- # cc, bug_group_map, user_group_map, and groups are in here so we
- # can check the permissions of flag requestees and email addresses
- # on the flag type cc: lists via the CanSeeBug
- # function call in Flag::notify. group_group_map is in here si
- # Bugzilla::User can flatten groups.
- 'bugs WRITE', 'profiles READ', 'email_setting READ',
- 'cc READ', 'bug_group_map READ', 'user_group_map READ',
- 'group_group_map READ', 'groups READ', 'group_control_map READ');
+ # Start a transaction in preparation for updating the attachment.
+ $dbh->bz_start_transaction();
# Quote the description and content type for use in the SQL UPDATE statement.
my $description = $cgi->param('description');
$attachment->isprivate, $updated_attachment->isprivate);
}
- # Unlock all database tables now that we are finished updating the database.
- $dbh->bz_unlock_tables();
+ # Commit the transaction now that we are finished updating the database.
+ $dbh->bz_commit_transaction();
# If the user submitted a comment while editing the attachment,
# add the comment to the bug.
$template->process("attachment/delete_reason.txt.tmpl", $vars, \$msg)
|| ThrowTemplateError($template->error());
- $dbh->bz_lock_tables('attachments WRITE', 'attach_data WRITE', 'flags WRITE');
+ $dbh->bz_start_transaction();
$dbh->do('DELETE FROM attach_data WHERE id = ?', undef, $attachment->id);
$dbh->do('UPDATE attachments SET mimetype = ?, ispatch = ?, isurl = ?,
isobsolete = ?
WHERE attach_id = ?', undef,
('text/plain', 0, 0, 1, $attachment->id));
$dbh->do('DELETE FROM flags WHERE attach_id = ?', undef, $attachment->id);
- $dbh->bz_unlock_tables;
+ $dbh->bz_commit_transaction();
# If the attachment is stored locally, remove it.
if (-e $attachment->_get_local_filename) {
profiles => [], # ['userid'],
};
-# Lock tables
-my @locked_tables = map {"$_ WRITE"} keys(%$changes);
-$dbh->bz_lock_tables(@locked_tables);
+# Start the transaction
+$dbh->bz_start_transaction();
# Delete old records from logincookies and tokens tables.
$dbh->do('DELETE FROM logincookies WHERE userid = ?', undef, $old_id);
# Delete the old record from the profiles table.
$dbh->do('DELETE FROM profiles WHERE userid = ?', undef, $old_id);
-# Unlock tables
-$dbh->bz_unlock_tables();
+# Commit the transaction
+$dbh->bz_commit_transaction();
print "Done.\n";
# If the query name contains invalid characters, don't import.
$name =~ /[<>&]/ && next;
trick_taint($name);
- $dbh->bz_lock_tables('namedqueries WRITE');
+ $dbh->bz_start_transaction();
my $query = $dbh->selectrow_array(
"SELECT query FROM namedqueries " .
"WHERE userid = ? AND name = ?",
"(userid, name, query) VALUES " .
"(?, ?, ?)", undef, ($userid, $name, $value));
}
- $dbh->bz_unlock_tables();
+ $dbh->bz_commit_transaction();
}
$cgi->remove_cookie($cookiename);
}
###########################################################################
# Role-based preferences
###########################################################################
- $dbh->bz_lock_tables("email_setting WRITE");
+ $dbh->bz_start_transaction();
# Delete all the user's current preferences
$dbh->do("DELETE FROM email_setting WHERE user_id = ?", undef, $user->id);
}
}
- $dbh->bz_unlock_tables();
+ $dbh->bz_commit_transaction();
###########################################################################
# User watching
&& (defined $cgi->param('new_watchedusers')
|| defined $cgi->param('remove_watched_users')))
{
- # Just in case. Note that this much locking is actually overkill:
- # we don't really care if anyone reads the watch table. So
- # some small amount of contention could be gotten rid of by
- # using user-defined locks rather than table locking.
- $dbh->bz_lock_tables('watch WRITE', 'profiles READ');
+ $dbh->bz_start_transaction();
# Use this to protect error messages on duplicate submissions
my $old_watch_ids =
}
}
- $dbh->bz_unlock_tables();
+ $dbh->bz_commit_transaction();
}
}
my $canedit = (Bugzilla->params->{'usevotes'} && $userid == $who) ? 1 : 0;
- $dbh->bz_lock_tables('bugs READ', 'products READ', 'votes WRITE',
- 'cc READ', 'bug_group_map READ', 'user_group_map READ',
- 'group_group_map READ', 'groups READ', 'group_control_map READ');
+ $dbh->bz_start_transaction();
if ($canedit && $bug_id) {
# Make sure there is an entry for this bug
}
$dbh->do('DELETE FROM votes WHERE vote_count <= 0');
- $dbh->bz_unlock_tables();
+ $dbh->bz_commit_transaction();
$vars->{'canedit'} = $canedit;
$vars->{'voting_user'} = { "login" => $name };