Closed Bug 277622 Opened 20 years ago Closed 20 years ago

Move DiffStrings() out of globals.pl into Bugzilla/Util.pm

Categories

(Bugzilla :: Bugzilla-General, enhancement)

2.19.1
enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 2.20

People

(Reporter: mkanat, Assigned: mkanat)

References

Details

Attachments

(1 file, 2 obsolete files)

This certainly is an interesting function... I'm surprised that there's nothing
built-in to Perl or any of the modules that we require that already does this.

Anyhow, it should be fairly easy to move this into Util.pm, and just rename it
to have the lowercase_underscore naming scheme. It's only used in three places.
Blocks: bz-globals
Attached patch Simple Patch (obsolete) — Splinter Review
Here's a basic patch that does the job. I just moved the code and re-named
things, and made sure that everybody was using Bugzilla::Util who needed to.

I tested the code to make sure that it works.
Attachment #170722 - Flags: review?
Comment on attachment 170722 [details] [diff] [review]
Simple Patch

>> Returns an array

It returns a list. See http://japhy.perlmonk.org/articles/pm/2000-02.html#2 for
a difference between lists and arrays, especially the "Lists vs. Arrays"
section and the "Return Values" section (where A() returns a lists and B()
returns an array, in non-scalar context).

+Takes two comma- or space-separated strings and returns what values

I'd say:

+Takes two strings with comma- or space-separated values

or something similar, because from the comment someone might understand that
the strings themselves are space-separated. There is no mention of the fact
that those strings contain values separated by comma or space until much later
in the sentence.

NIT: we might also say that the items returned are always comma separated.
Attachment #170722 - Flags: review? → review-
Comment on attachment 170722 [details] [diff] [review]
Simple Patch

+... added items.

NIT: we could use the same terminology (either values or items) to be
consisntant, but that's a nit also.
Attached patch Version 2Splinter Review
Wow, thank you for that very helpful review. :-) I was confused about the
documentation, myself -- I'm glad that now we'll have hopefully clear API
documentation. (Now *I* also understand what the function is supposed to do.
:-) )
Attachment #170722 - Attachment is obsolete: true
Attachment #170795 - Flags: review?
Comment on attachment 170795 [details] [diff] [review]
Version 2

>+compared to the old one. Returns a list, where the first entry is a scalar
>+containing removed items, and the second entry is a scalar containing added
>+items.

Nit: Returns a list, where the first entry is a reference to a list containing
the removed items, and the second entry is a reference to a list containing the
added items.
Attached patch Version 3 (obsolete) — Splinter Review
OK, I corrected justdave's (very valid) nit.
Attachment #170795 - Attachment is obsolete: true
Attachment #170796 - Flags: review?
Attachment #170795 - Flags: review?
(In reply to comment #6)
> Created an attachment (id=170796) [edit]
> Version 3
> 
> OK, I corrected justdave's (very valid) nit.

Ummm, errr....   Oops.

Take version 2.  I didn't read the patch close enough.

It returns strings with "comma+space" separated human-readable lists in those
strings.
(In reply to comment #7)

> It returns strings with "comma+space" separated human-readable lists in those
> strings.

Having it return references to lists might actually make the function a little
cleaner, and allow the caller to be more flexible with the results...  On the
other hand, everyplace currently using it is using it with the intention of
producing an entry in the activity table, which wants it as a string anyway
(currently anyway -- there's another bug somewhere suggesting that we change
that, and have a separate entry for each added and removed item instead of comma
lists, to make searches more accurate)

Probably better to leave it like it is for now, and we can change it to return
lists as part of the above bug.
Comment on attachment 170796 [details] [diff] [review]
Version 3

OK, then this version is incorrect. :-)
Attachment #170796 - Attachment is obsolete: true
Attachment #170796 - Flags: review?
Comment on attachment 170795 [details] [diff] [review]
Version 2

And this version needs a very brief review. :-)
Attachment #170795 - Attachment is obsolete: false
Attachment #170795 - Flags: review?
Attachment #170795 - Flags: review? → review+
Status: NEW → ASSIGNED
Flags: approval?
Target Milestone: --- → Bugzilla 2.22
Whiteboard: patch awaiting approval
Targeting bug to 2.20 since the 2.20 feature freeze was canceled.
Target Milestone: Bugzilla 2.22 → Bugzilla 2.20
Flags: approval? → approval+
Checking in globals.pl;
/cvsroot/mozilla/webtools/bugzilla/globals.pl,v  <--  globals.pl
new revision: 1.281; previous revision: 1.280
done
Checking in process_bug.cgi;
/cvsroot/mozilla/webtools/bugzilla/process_bug.cgi,v  <--  process_bug.cgi
new revision: 1.223; previous revision: 1.222
done
Checking in Bugzilla/Flag.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Flag.pm,v  <--  Flag.pm
new revision: 1.28; previous revision: 1.27
done
Checking in Bugzilla/Util.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Util.pm,v  <--  Util.pm
new revision: 1.15; previous revision: 1.14
done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Summary: Move DiffStrings() out of globals.pl → Move DiffStrings() out of globals.pl into Bugzilla/Util.pm
Whiteboard: patch awaiting approval
QA Contact: matty_is_a_geek → default-qa
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: