summaryrefslogtreecommitdiffstats
path: root/extensions/Example
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2012-04-17 20:56:41 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2012-04-17 20:56:41 +0200
commit9a5a196d79ed8692c45595c4e3d42e34571bc3a7 (patch)
tree058a2aba35e324354547f7d45e504282b3eb98a5 /extensions/Example
parent3b2fcf526e02c1d74f88b567083a9be371d5a607 (diff)
downloadbugzilla-9a5a196d79ed8692c45595c4e3d42e34571bc3a7.tar.gz
bugzilla-9a5a196d79ed8692c45595c4e3d42e34571bc3a7.tar.xz
Bug 745197: Add a hook in Bugzilla::Error::_throw_error() so that extensions can control the way to throw errors
r=dkl a=LpSolit
Diffstat (limited to 'extensions/Example')
-rw-r--r--extensions/Example/Extension.pm19
1 files changed, 19 insertions, 0 deletions
diff --git a/extensions/Example/Extension.pm b/extensions/Example/Extension.pm
index 5cd6a1d29..62fb345d9 100644
--- a/extensions/Example/Extension.pm
+++ b/extensions/Example/Extension.pm
@@ -340,6 +340,25 @@ sub enter_bug_entrydefaultvars {
$vars->{'example'} = 1;
}
+sub error_catch {
+ my ($self, $args) = @_;
+ # Customize the error message displayed when someone tries to access
+ # page.cgi with an invalid page ID, and keep track of this attempt
+ # in the web server log.
+ return unless Bugzilla->error_mode == ERROR_MODE_WEBPAGE;
+ return unless $args->{error} eq 'bad_page_cgi_id';
+
+ my $page_id = $args->{vars}->{page_id};
+ my $login = Bugzilla->user->identity || "Someone";
+ warn "$login attempted to access page.cgi with id = $page_id";
+
+ my $page = $args->{message};
+ my $new_error_msg = "Ah ah, you tried to access $page_id? Good try!";
+ $new_error_msg = html_quote($new_error_msg);
+ # There are better tools to parse an HTML page, but it's just an example.
+ $$page =~ s/(?<=<td id="error_msg" class="throw_error">).*(?=<\/td>)/$new_error_msg/si;
+}
+
sub flag_end_of_update {
my ($self, $args) = @_;