Bugzilla - Semi-persistent collection of various objects used by scripts and modules


  use Bugzilla;

  sub someModulesSub {


Several Bugzilla 'things' are used by a variety of modules and scripts. This includes database handles, template objects, and so on.

This module is a singleton intended as a central place to store these objects. This approach has several advantages:

Note that items accessible via this object are demand-loaded when requested.

For something to be added to this object, it should either be able to benefit from persistence when run under mod_perl (such as the a template object), or should be something which is globally required by a large ammount of code (such as the current user object).


Note that all Bugzilla functionality is method based; use Bugzilla->dbh rather than Bugzilla::dbh. Nothing cares about this now, but don't rely on that.


The current Template object, to be used for output


If you ever need a Bugzilla::Template object while you're already processing a template, use this. Also use it if you want to specify the language to use. If no argument is passed, it uses the last language set. If the argument is "" (empty string), the language is reset to the current one (the one used by Bugzilla->template).


The current cgi object. Note that modules should not be using this in general. Not all Bugzilla actions are cgi requests. Its useful as a convenience method for those scripts/templates which are only use via CGI, though.


undef if there is no currently logged in user or if the login code has not yet been run. If an sudo session is in progress, the Bugzilla::User corresponding to the person who is being impersonated. If no session is in progress, the current Bugzilla::User.


Allows you to directly set what "user" will return. You can use this if you want to bypass "login" for some reason and directly "log in" a specific Bugzilla::User. Be careful with it, though!


undef if there is no currently logged in user, the currently logged in user is not in the sudoer group, or there is no session in progress. If an sudo session is in progress, returns the Bugzilla::User object corresponding to the person who logged in and initiated the session. If no session is in progress, returns the Bugzilla::User object corresponding to the currently logged in user.

sudo_request This begins an sudo session for the current request. It is meant to be used when a session has just started. For normal use, sudo access should normally be set at login time.

Logs in a user, returning a Bugzilla::User object, or undef if there is no logged in user. See Bugzilla::Auth, and Bugzilla::User.


Logs out the current user, which involves invalidating user sessions and cookies. Three options are available from Bugzilla::Constants: LOGOUT_CURRENT (the default), LOGOUT_ALL or LOGOUT_KEEP_CURRENT.


Logs out the specified user (invalidating all his sessions), taking a Bugzilla::User instance.


Logs out the user with the id specified. This is a compatibility function to be used in callsites where there is only a userid and no Bugzilla::User instance.


Essentially, causes calls to Bugzilla->user to return undef. This has the effect of logging out a user for the current request only; cookies and database sessions are left intact.


Call either Bugzilla-error_mode(Bugzilla::Constants::ERROR_MODE_DIE)> or Bugzilla-error_mode(Bugzilla::Constants::ERROR_MODE_DIE_SOAP_FAULT)> to change this flag's default of Bugzilla::Constants::ERROR_MODE_WEBPAGE and to indicate that errors should be passed to error mode specific error handlers rather than being sent to a browser and finished with an exit().

This is useful, for example, to keep eval blocks from producing wild HTML on errors, making it easier for you to catch them. (Remember to reset the error mode to its previous value afterwards, though.)

Bugzilla-error_mode> will return the current state of this flag.

Note that Bugzilla-error_mode> is being called by Bugzilla-usage_mode> on usage mode changes.


Call either Bugzilla-usage_mode(Bugzilla::Constants::USAGE_MODE_CMDLINE)> or Bugzilla-usage_mode(Bugzilla::Constants::USAGE_MODE_WEBSERVICE)> near the beginning of your script to change this flag's default of Bugzilla::Constants::USAGE_MODE_BROWSER and to indicate that Bugzilla is being called in a non-interactive manner. This influences error handling because on usage mode changes, usage_mode calls Bugzilla-error_mode> to set an error mode which makes sense for the usage mode.

Bugzilla-usage_mode> will return the current state of this flag.


Determines whether or not installation should be silent. See Bugzilla::Constants for the INSTALLATION_MODE constants.


Returns a hashref representing any "answers" file passed to checksetup.pl, used to automatically answer or skip prompts.


The current database handle. See DBI.


Currently installed languages. Returns a reference to a list of RFC 1766 language tags of installed languages.


Switch from using the main database to using the shadow database.


Change the database object to refer to the main database.


The current Parameters of Bugzilla, as a hashref. If data/params does not exist, then we return an empty hashref. If data/params is unreadable or is not valid perl, we die.


If you are running inside a code hook (see Bugzilla::Hook) this is how you get the arguments passed to the hook.