From: lpsolit%gmail.com <> Date: Wed, 30 Jul 2008 04:59:55 +0000 (+0000) Subject: Bug 448391: Bug->create() should make sure the reporter is logged in - Patch by FrÃ... X-Git-Tag: bugzilla-3.2rc1~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d757e02154a92e425b30a863b4bd24784eba7c1;p=thirdparty%2Fbugzilla.git Bug 448391: Bug->create() should make sure the reporter is logged in - Patch by Frédéric Buclin r/a=mkanat --- diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 182b458e08..7fb47626b4 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -467,7 +467,7 @@ sub run_create_validators { $params->{cc} = $class->_check_cc($component, $params->{cc}); # Callers cannot set Reporter, currently. - $params->{reporter} = Bugzilla->user->id; + $params->{reporter} = $class->_check_reporter(); $params->{creation_ts} ||= Bugzilla->dbh->selectrow_array('SELECT NOW()'); $params->{delta_ts} = $params->{creation_ts}; @@ -1334,6 +1334,22 @@ sub _check_rep_platform { return $platform; } +sub _check_reporter { + my $invocant = shift; + my $reporter; + if (ref $invocant) { + # You cannot change the reporter of a bug. + $reporter = $invocant->reporter->id; + } + else { + # On bug creation, the reporter is the logged in user + # (meaning that he must be logged in first!). + $reporter = Bugzilla->user->id; + $reporter || ThrowCodeError('invalid_user'); + } + return $reporter; +} + sub _check_resolution { my ($self, $resolution) = @_; $resolution = trim($resolution);