diff options
author | Byron Jones <bjones@mozilla.com> | 2012-11-20 14:51:09 +0100 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2012-11-20 14:51:09 +0100 |
commit | 254b841d56c1ee59851eb83234d9cc53ca90dae2 (patch) | |
tree | 992b53cefec4c93a1a5a0e4f1b8920adb028854f | |
parent | 2cfc2817d82789162a99aaffe37200cb3b440853 (diff) | |
download | bugzilla-254b841d56c1ee59851eb83234d9cc53ca90dae2.tar.gz bugzilla-254b841d56c1ee59851eb83234d9cc53ca90dae2.tar.xz |
Avoid loading Push ext unless updating bugs
-rw-r--r-- | extensions/Push/Extension.pm | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/extensions/Push/Extension.pm b/extensions/Push/Extension.pm index f48a60210..822d8da6d 100644 --- a/extensions/Push/Extension.pm +++ b/extensions/Push/Extension.pm @@ -40,14 +40,15 @@ BEGIN { *Bugzilla::push_ext = \&_get_instance; } -my $_instance; sub _get_instance { - if (!$_instance) { - $_instance = Bugzilla::Extension::Push::Push->new(); - $_instance->logger(Bugzilla::Extension::Push::Logger->new()); - $_instance->connectors(Bugzilla::Extension::Push::Connectors->new()); + my $cache = Bugzilla->request_cache; + if (!$cache->{'push.instance'}) { + my $instance = Bugzilla::Extension::Push::Push->new(); + $cache->{'push.instance'} = $instance; + $instance->logger(Bugzilla::Extension::Push::Logger->new()); + $instance->connectors(Bugzilla::Extension::Push::Connectors->new()); } - return $_instance; + return $cache->{'push.instance'}; } # @@ -332,14 +333,18 @@ sub object_end_of_create { sub object_end_of_update { my ($self, $args) = @_; + + # User objects are updated with every page load (to touch the session + # token). Because we ignore user objects, there's no need to create an + # instance of Push to check if we're enabled. + my $object = _get_object_from_args($args); + return if !$object || $object->isa('Bugzilla::User'); + return unless $self->_enabled; # it's better to process objects from a non-generic end_of_update where # possible; don't process them here to avoid duplicate messages - my $object = _get_object_from_args($args); - return if !$object || - $object->isa('Bugzilla::Bug') || - $object->isa('Bugzilla::Flag'); + return if $object->isa('Bugzilla::Bug') || $object->isa('Bugzilla::Flag'); $self->_object_modified($args); } |