Closed Bug 783222 Opened 12 years ago Closed 12 years ago

Make set_all() throw error on invalid param names

Categories

(Bugzilla :: Bugzilla-General, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 4.4

People

(Reporter: koosha.khajeh, Assigned: koosha.khajeh)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch patch - v1 (obsolete) — Splinter Review
      No description provided.
Attachment #652397 - Flags: review?(dkl)
Attachment #652397 - Flags: review?(LpSolit)
Comment on attachment 652397 [details] [diff] [review]
patch - v1

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

Looks fine and works as expected. r=dkl
Attachment #652397 - Flags: review?(dkl) → review+
Flags: approval?
Comment on attachment 652397 [details] [diff] [review]
patch - v1

>+    # First check for any invalid method then proceed to call those methods
>+    foreach my $key (@sorted_names) {
>+        next if !exists $field_values{$key};
>+        my $method = "set_$key";

Please don't duplicate code. This is the exact same code as the following loop. It's fine to check if a method exists and call it immediately if it does. I don't see the point to do this check separately.


>+        if (!$self->can($method)) {
>+            my $class = ref($self) || $self;
>+            ThrowCodeError("unknown_method", { method => "${class}::${method}" });
>+        }

This is the only code you need to add, in the existing loop and right before the method is called.
Attachment #652397 - Flags: review?(LpSolit) → review-
Flags: approval?
Attached patch patch - v1.1Splinter Review
Attachment #652397 - Attachment is obsolete: true
Attachment #657378 - Flags: review?(LpSolit)
Comment on attachment 657378 [details] [diff] [review]
patch - v1.1

Looks good. r=LpSolit
Attachment #657378 - Flags: review?(LpSolit) → review+
Flags: approval4.4+
Flags: approval+
Committing to: bzr+ssh://dlawrence%40mozilla.com@bzr.mozilla.org/bugzilla/4.4
modified Bugzilla/Object.pm
Committed revision 8374.

Committing to: bzr+ssh://dlawrence%40mozilla.com@bzr.mozilla.org/bugzilla/trunk
modified Bugzilla/Object.pm
Committed revision 8376.
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Please remove my IRC nick ([:koosha]) from my name on bzr. Thanks. :-)
(In reply to Koosha Khajeh Moogahi [:koosha] from comment #7)
> Please remove my IRC nick ([:koosha]) from my name on bzr. Thanks. :-)

Sorry bout that. From looking around, I do not see a way to edit a previous commits attributes such as author without manual editing on the bzr server. Maybe someone else has an idea. I will be more careful in the future to not include your IRC nick.

dkl
Blocks: 419568, 777047, 777499
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: