From 2d757e02154a92e425b30a863b4bd24784eba7c1 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Wed, 30 Jul 2008 04:59:55 +0000 Subject: [PATCH] =?utf8?q?Bug=20448391:=20Bug->create()=20should=20make=20?= =?utf8?q?sure=20the=20reporter=20is=20logged=20in=20-=20Patch=20by=20Fr?= =?utf8?q?=C3=83=C2=A9d=C3=83=C2=A9ric=20Buclin=20=20r/?= =?utf8?q?a=3Dmkanat?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Bugzilla/Bug.pm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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); -- 2.47.2