Bug 405788: $bug->add_comment incorrectly calls check_can_change_field() - Patch by Fr��d��ric Buclin <LpSolit@gmail.com> r/a=mkanat

This commit is contained in:
lpsolit%gmail.com 2007-11-29 19:54:25 +00:00
Родитель 08a39af551
Коммит e511fa0b64
1 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -1565,10 +1565,6 @@ sub add_comment {
my ($self, $comment, $params) = @_; my ($self, $comment, $params) = @_;
$comment = $self->_check_comment($comment); $comment = $self->_check_comment($comment);
# XXX At some point we need to refactor check_can_change_field
# so that custom installs can use PrivilegesRequired here.
$self->check_can_change_field('longdesc')
|| ThrowUserError('illegal_change', { field => 'longdesc' });
$params ||= {}; $params ||= {};
if (exists $params->{work_time}) { if (exists $params->{work_time}) {
@ -1589,6 +1585,11 @@ sub add_comment {
return; return;
} }
# So we really want to comment. Make sure we are allowed to do so.
my $privs;
$self->check_can_change_field('longdesc', 0, 1, \$privs)
|| ThrowUserError('illegal_change', { field => 'longdesc', privs => $privs });
$self->{added_comments} ||= []; $self->{added_comments} ||= [];
my $add_comment = dclone($params); my $add_comment = dclone($params);
$add_comment->{thetext} = $comment; $add_comment->{thetext} = $comment;