Closed Bug 279740 Opened 20 years ago Closed 20 years ago

Move CountOpenDependencies out of globals.pl

Categories

(Bugzilla :: Creating/Changing Bugs, enhancement)

2.19.2
enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 2.20

People

(Reporter: mkanat, Assigned: mkanat)

References

Details

Attachments

(1 file)

This function is only used in process_bug.cgi, that I can see. It should also be
renamed, probably OpenDependencyList or get_open_deps.
Severity: normal → enhancement
Status: NEW → ASSIGNED
Just a simple move, and I changed the SendSQL calls to DBI calls. It's only
used in process_bug, so it was easy to test the change.
Attachment #172342 - Flags: review?
Comment on attachment 172342 [details] [diff] [review]
Move it and make it use DBI

Tested; works.

I can't think of a way to make that IN part use bound parameters, so let's keep
it the way it is.

It's a pity we can't get rid of &::OpenStates in favour of
Bugzilla::Util::OpenStates yet :)

>+    my $sth = $dbh->prepare(
>+          "SELECT blocked, count(bug_status) " .
>+            "FROM bugs, dependencies " .
>+           "WHERE blocked IN (" . (join "," , @bug_list) . ") " .
>+             "AND bug_id = dependson " .
>+             "AND bug_status IN ('" . (join "','", &::OpenStates())  . "') " .
>+        "GROUP BY blocked ");
>+    $sth->execute();
>+
>+    while (my ($bug_id, $dependencies) = $sth->fetchrow_array()) {
>+        push(@dependencies, { bug_id       => $bug_id,
>+                              dependencies => $dependencies });
>+    }
>+
>+    return @dependencies;

Nit: how about

>+    return @{$dbh->selectall_arrayref('SELECT blocked AS bug_id ...',
>+                                      {'Slice' => {}})};

for readability and efficience?
Attachment #172342 - Flags: review? → review+
Yeah, I looked at the DBI docs, and they practically say outright that you can't
use placeholders with an IN clause.

I prefer the way that the code is written now, instead of the modified return
statement, overall. I agree that the Slice thing might be better, but I don't
really want to re-work the patch to use it. Anyhow, I think that this ends up
being clearer, overall, for those who aren't as familiar with DBI.
Flags: approval?
Flags: approval? → approval+
Target Milestone: --- → Bugzilla 2.20
Checking in globals.pl;
/cvsroot/mozilla/webtools/bugzilla/globals.pl,v  <--  globals.pl
new revision: 1.294; previous revision: 1.293
done
Checking in process_bug.cgi;
/cvsroot/mozilla/webtools/bugzilla/process_bug.cgi,v  <--  process_bug.cgi
new revision: 1.231; previous revision: 1.230
done
Checking in Bugzilla/Bug.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Bug.pm,v  <--  Bug.pm
new revision: 1.51; previous revision: 1.50
done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: