Closed Bug 278010 Opened 20 years ago Closed 20 years ago

checksetup.pl should fix empty group names

Categories

(Bugzilla :: Installation & Upgrading, defect)

2.18
defect
Not set
major

Tracking

()

RESOLVED FIXED
Bugzilla 2.20

People

(Reporter: LpSolit, Assigned: nb+bz)

References

Details

Attachments

(2 files)

When viewing a bug when I'm logged out or using an account without privs, there
is no problem. Doing the same with an account having (admin) privs, show_bug.cgi
crashed with the error message I will attach.

No group is defined for the timetracking group. I just upgraded to the latest
version of 2.18 from CVS (after erik chechin).

This problem does not appear on the trunk. I haven't time to investigate...
Flags: blocking2.18?
Priority: -- → P1
I can't reproduce this any way I try. I started with a blank directory, checked
out 2.18, and had checksetup create the database. I have one user (the admin),
and I can access bugs even when I:

+ File a new bug, without setting any params at all.
+ Edit the params, but leave timetrackinggroup blank.
+ Turn on timetracking group
+ Enter timetracking information and then turn off timetrackinggroup

I'm assuming that this is not actually a totally "fresh" installation of
Bugzilla, since you must have bugs in your DB in order to access show_bug.
Severity: blocker → critical
Priority: P1 → --
OK, I have found the reason why I got this error:

As I said in IRC, this is related to the timetracking group which is empty in my
installations (both the 2.18rc3+ and 2.19.1+ ones). As I was testing my patch
for bug 277768, I had previously set a group with no name in my 2.18 branch
installation, where I did not apply my patch. [This is allowed per my comment in
bug 277768: no check is made when renaming a group so that you can delete it and
you get no error!]

So: when show_bug.cgi is called, you also call the Bug.pm and
default/bug/edit.html.tmpl files. And here is where the problem is:

From Bugzilla/Bug.pm, line 64:

    if (Param('timetrackinggroup')) {
        push @fields, qw(estimated_time remaining_time actual_time);
    }

As timetrackinggroup is empty (''), the test is wrong and you don't add these
three fields to the list (among which: remaining_time !)

    
From template/en/default/bug/edit.html.tmpl, line 94:

[% IF UserInGroup(Param('timetrackinggroup')) %]
  var fRemainingTime = [% bug.remaining_time %]; // holds the original value

Here, Param('timetrackinggroup') is still empty *but* a group with an empty
group name *exists* (the one with no name mentionned before)! Then, for all
users which are in this group without name (especially users in the admin group,
by inheritance), this test is *true* and we have to consider the
"bug.remaining_time" term which is not allowed by Bug.pm because remaining_time
has not been added to the field list, giving us the error message attached to
this bug.

Wow! :-p

Then, this bug is not a dupe of bug 277768 as it purpose is not to check group
names (among others), but is blocked by it.

Maybe should we add a patch here so that checksetup.pl checks if there is a
group with an empty name? This would be trivial to do.
Depends on: 277768
Flags: blocking2.20?
Summary: Cannot access show_bug.cgi on the 2.18 branch → Cannot access show_bug.cgi if the timetrackinggroup is empty and a group has no name and you belong to that group
(In reply to comment #3)
> Then, this bug is not a dupe of bug 277768 as it purpose is not to check group
> names (among others), but is blocked by it.
> 
> Maybe should we add a patch here so that checksetup.pl checks if there is a
> group with an empty name? This would be trivial to do.
> 

Humm... to be more precise, bug 277768 is about editgroups.cgi and this one
would be about checksetup.pl. We could merge both in a single patch but I prefer
having two actually.
Patch for 2.18 tip checksetup.pl, to fix an empty group name.
Attachment #171087 - Flags: review?
This should be fixed, but this is one of those situations that's not likely to
happen often, and the admin should know better ;)  I'll take it on the branch,
but this won't block release.
Severity: critical → major
Flags: blocking2.20?
Flags: blocking2.20-
Flags: blocking2.18?
Flags: blocking2.18-
Target Milestone: --- → Bugzilla 2.18
Comment on attachment 171087 [details] [diff] [review]
checksetup.pl patch to fix empty group names

I can reproduce this on HEAD, too. The patch applies there.

Tested; works. I you don't wish to address my nits below, just request approval
and approval2.18.

>+        if ($trycount > 0) {
>+            $trygroupname .= "_$trycount";
>+        }
>+        $trygroupsth->execute($trygroupname);
>+        if ($trygroupsth->rows > 0) {
>+            $trycount ++;
>+        }

Nit: you could say if (++$trycount > 1) { $trygroupname .= "_$trycount"; } and
scrap the second if(){} block. (Numbering would start with 2 then, though.)

>+    $sth = $dbh->prepare("UPDATE groups SET name = ? WHERE id = $emptygroupid");
>+    $sth->execute($trygroupname);

Nit: these two can be merged into one $dbh->do().
Attachment #171087 - Flags: review? → review+
Let's get this in.
Flags: approval?
Flags: approval2.18?
Whiteboard: patch awaiting approval
This will have to be relnoted, so I'd rather put it in 2.18.1 as the relnotes
for 2.18 are already written and seem to have general approval.
Keywords: relnote
Summary: Cannot access show_bug.cgi if the timetrackinggroup is empty and a group has no name and you belong to that group → checksetup.pl should fix empty group names
Component: Bugzilla-General → Installation & Upgrading
Assignee: justdave → Nick.Barnes
Flags: approval? → approval+
I'm not checking this in until the 2.18? is either approved or goes away (in 
case you're wondering what the holdup is).
Flags: approval2.18? → approval2.18-
Target Milestone: Bugzilla 2.18 → Bugzilla 2.20
Whiteboard: patch awaiting approval → patch awaiting checkin
Checking in checksetup.pl;
/cvsroot/mozilla/webtools/bugzilla/checksetup.pl,v  <--  checksetup.pl
new revision: 1.330; previous revision: 1.329
done
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Whiteboard: patch awaiting checkin
This has been added to the release notes in bug 297590.
Keywords: relnote
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: