Add a check_for_edit to Bugzilla::Bug to return the bug object if the user can edit the bug

RESOLVED FIXED in Bugzilla 4.4

Status

()

--
enhancement
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: rowebb, Assigned: rowebb)

Tracking

unspecified
Bugzilla 4.4
Bug Flags:
approval +

Details

Attachments

(1 attachment, 2 obsolete attachments)

(Assignee)

Description

7 years ago
There should be a check_for_edit method in Bugzilla::Bug that will run check and take that bug and run can_edit_product. This will either throw a user error if they do not have permissions to edit the bug or will return the created bug object.

Comment 1

7 years ago
IMO, this doesn't make sense. It should be a User object method, like $user->can_edit_bug($bug)

Comment 2

7 years ago
No, it's:

  my $bug = Bugzilla::Bug->check_for_edit($id);
(Assignee)

Comment 3

7 years ago
Created attachment 556967 [details] [diff] [review]
Adding check_for_edit to Bugzilla::Bug
Attachment #556967 - Flags: review?(mkanat)

Comment 4

7 years ago
Comment on attachment 556967 [details] [diff] [review]
Adding check_for_edit to Bugzilla::Bug

Review of attachment 556967 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good on the implementation, but in order for us to accept patches, we require that the code actually be used somewhere. So just convert all the places where we call check() and then can_edit_product into a call to this.
Attachment #556967 - Flags: review?(mkanat) → review-
(Assignee)

Comment 5

7 years ago
Created attachment 557026 [details] [diff] [review]
Adding check_for_edit to Bugzilla::Bug change v2

Updated the changes and patched all of the places where User->can_edit_product is called after Bug->check.
Attachment #556967 - Attachment is obsolete: true
Attachment #557026 - Flags: review?(mkanat)

Comment 6

7 years ago
Comment on attachment 557026 [details] [diff] [review]
Adding check_for_edit to Bugzilla::Bug change v2

Review of attachment 557026 [details] [diff] [review]:
-----------------------------------------------------------------

Beautiful! This is a very nice cleanup. :-)
Attachment #557026 - Flags: review?(mkanat) → review+

Updated

7 years ago
Flags: approval+
Target Milestone: --- → Bugzilla 5.0

Comment 7

7 years ago
Comment on attachment 557026 [details] [diff] [review]
Adding check_for_edit to Bugzilla::Bug change v2

>=== modified file 'Bugzilla/Bug.pm'

>+    Bugzilla->user->can_edit_product($bug->{product_id})

Nit: should be ->product_id instead of ->{product_id}
(Assignee)

Updated

7 years ago
Status: NEW → ASSIGNED
(Assignee)

Comment 8

7 years ago
Created attachment 557331 [details] [diff] [review]
Adding check_for_edit to Bugzilla::Bug change v3

Updating the diff for the nit pick.
Attachment #557026 - Attachment is obsolete: true

Updated

7 years ago
Attachment #557331 - Flags: review+

Comment 9

7 years ago
Committing to: bzr+ssh://bzr.mozilla.org/bugzilla/trunk/
modified process_bug.cgi
modified Bugzilla/Bug.pm
modified Bugzilla/BugUrl/Bugzilla/Local.pm
modified Bugzilla/WebService/Bug.pm
Committed revision 7949.
Status: ASSIGNED → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.