Closed Bug 360626 Opened 18 years ago Closed 15 years ago

ThrowTemplateError() used in Util.pm

Categories

(Bugzilla :: Bugzilla-General, defect)

2.23.3
defect
Not set
minor

Tracking

()

RESOLVED FIXED
Bugzilla 3.4

People

(Reporter: LpSolit, Assigned: reed)

References

Details

Attachments

(1 file, 1 obsolete file)

While working on a patch, I reached ThrowTemplateError() in Util::get_text():

    $template->process('global/message.txt.tmpl', $vars, \$message)
        || ThrowTemplateError($template->error());

But this routine isn't defined:

Undefined subroutine &Bugzilla::Util::ThrowTemplateError called at Bugzilla/Util.pm line 498.

Util.pm cannot |use Bugzilla::Error;| because Error.pm already uses Util.pm. I remember we moved all code throwing errors out of Util.pm. Maybe should we do the same with get_text() and move it into Template.pm. After all, get_text() is a template thing.
I seem to recall that get_text doesn't work inside Bugzilla::Template, for dependency reasons or something. I think I originally put it there, and I had some problem. Maybe not, though.
Depends on: 387672
Assignee: general → LpSolit
Target Milestone: Bugzilla 3.0 → Bugzilla 3.2
Target Milestone: Bugzilla 3.2 → ---
Confirmed for 3.02. It seems as if this also inhibits the presentation of non-english localisation email templates: If "defaultlanguage" is set to the default "en" and "languages" to a different locale ("de"), mails are still sent in "en" although translated templates are present in ../de/default/email/. Wouldn`t it make more sense to connect the mail template language to the default "languages" instead (unless users have individual settings) ?
(In reply to comment #3)
> It seems as if this also inhibits the presentation of
> non-english localisation email templates:

  No, that would be unrelated to this bug.
Assignee: LpSolit → general
Summary: ThrowTemplateError() used in Util.pm → ThrowTemplateError() and ThrowUserError() used in Util.pm
ThrowUserError() is used in SqlifyDate() inside of Util.pm... Thoughts?
require Bugzilla::Error inside the relevant subroutines.
Summary: ThrowTemplateError() and ThrowUserError() used in Util.pm → ThrowTemplateError() used in Util.pm
Attached patch patch - v1 (obsolete) — Splinter Review
something like this?
Attachment #412738 - Flags: review?(LpSolit)
Attachment #412738 - Flags: review?(LpSolit) → review-
Comment on attachment 412738 [details] [diff] [review]
patch - v1

>+    require Bugzilla::Error;
>     $template->process('global/message.txt.tmpl', $vars, \$message)
>         || ThrowTemplateError($template->error());

|require| doesn't automatically import ThrowTemplateError(). You have to use the full "path" Bugzilla::Error::ThrowTemplateError. Now, as this error isn't going to happen very often, I wonder if it's a good idea to waste cycle require'ing Bugzilla::Error everytime get_text() is called. I think something like this would be better:

if (!$template->...) {
    require Bugzilla::Error;
    Bugzilla::Error::ThrowTemplateError()
}
Attached patch patch - v2Splinter Review
Neat.
Assignee: general → reed
Attachment #412738 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #413106 - Flags: review?(LpSolit)
Attachment #413106 - Flags: review?(LpSolit) → review+
Severity: normal → minor
Flags: approval3.4+
Flags: approval+
Target Milestone: --- → Bugzilla 3.4
tip:

Checking in Bugzilla/Util.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Util.pm,v  <--  Util.pm
new revision: 1.97; previous revision: 1.96
done

BUGZILLA-3_4-BRANCH:

Checking in Bugzilla/Util.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/Util.pm,v  <--  Util.pm
new revision: 1.86.2.4; previous revision: 1.86.2.3
done
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
By the way, "require" is very fast it doesn't have to load the module--it's just checking %INC, which is just a hash-key check.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: