From: Kohei Yoshino Date: Tue, 28 May 2019 18:51:11 +0000 (-0400) Subject: Bug 1543489 - Update firefox-crash-table.js to use cached firefox_versions.json X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=088d15b664514830025762237b09c123853435cb;p=thirdparty%2Fbugzilla.git Bug 1543489 - Update firefox-crash-table.js to use cached firefox_versions.json --- diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm index f1e98c1cd..50dba3d70 100644 --- a/extensions/BMO/Extension.pm +++ b/extensions/BMO/Extension.pm @@ -174,6 +174,7 @@ sub template_before_process { } } elsif ($file eq 'bug/edit.html.tmpl' || $file eq 'bug_modal/edit.html.tmpl') { + $vars->{firefox_versions} = _fetch_product_version_file('firefox', 1); $vars->{split_cf_crash_signature} = $self->_split_crash_signature($vars); } @@ -2664,12 +2665,14 @@ sub enter_bug_entrydefaultvars { } } -sub _get_product_version { - my ($product, $channel, $detail) = @_; +sub _fetch_product_version_file { + my ($product, $cache_only) = @_; my $key = "${product}_versions"; my $versions = Bugzilla->request_cache->{$key} || Bugzilla->memcached->get_data({key => $key}); + return $versions if $cache_only; + unless ($versions) { my $ua = Mojo::UserAgent->new; if (my $proxy_url = Bugzilla->params->{'proxy_url'}) { @@ -2687,6 +2690,12 @@ sub _get_product_version { }); } + return $versions; +} + +sub _get_product_version { + my ($product, $channel, $detail) = @_; + my $versions = _fetch_product_version_file($product); my $version = $versions->{PRODUCT_CHANNELS->{$product}->{$channel}->{json_key}}; return $version if $detail; diff --git a/extensions/BMO/template/en/default/hook/bug_modal/edit-after_modules.html.tmpl b/extensions/BMO/template/en/default/hook/bug_modal/edit-after_modules.html.tmpl index 0723eba01..7b9cceaa3 100644 --- a/extensions/BMO/template/en/default/hook/bug_modal/edit-after_modules.html.tmpl +++ b/extensions/BMO/template/en/default/hook/bug_modal/edit-after_modules.html.tmpl @@ -7,3 +7,7 @@ #%] [% INCLUDE bug/legal_disclaimer.html.tmpl %] + +[% IF firefox_versions %] + +[% END %] diff --git a/extensions/BMO/web/js/firefox-crash-table.js b/extensions/BMO/web/js/firefox-crash-table.js index 5cc164c02..26919dbf1 100644 --- a/extensions/BMO/web/js/firefox-crash-table.js +++ b/extensions/BMO/web/js/firefox-crash-table.js @@ -12,6 +12,12 @@ window.addEventListener('DOMContentLoaded', () => { const VERSION = "0.4.0"; async function fetchProductDetails() { + const $meta = document.querySelector('meta[name="firefox-versions"]'); + + if ($meta) { + return JSON.parse($meta.content); + } + const url = "https://product-details.mozilla.org/1.0/firefox_versions.json"; const response = await fetch(url); return await response.json();