From: Vladimir Panteleev Date: Sat, 13 Feb 2021 17:31:03 +0000 (+0000) Subject: Bug 1450405: Remove cf_crash_signature references (#77) X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=f0a2fe30be3ddb6e7cfed367bd4634c004f373c6;p=thirdparty%2Fbugzilla.git Bug 1450405: Remove cf_crash_signature references (#77) This is a Mozilla-specific field which has not been properly encapsulated into the BMO extension, where most of its implementation lies. Remove the hard-coded references occurring outside the BMO extension. This fixes an internal error ("Can't use cf_crash_signature as a field name."). Co-authored-by: Dylan Hardison --- diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 77804bee0..0ec61eab1 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -412,9 +412,9 @@ sub ES_SELECT_UPDATED_SQL { my ($class, $mtime) = @_; my @fields = ( - 'keywords', 'short_desc', 'product', 'component', - 'cf_crash_signature', 'alias', 'status_whiteboard', 'bug_status', - 'resolution', 'priority', 'assigned_to', 'bug_type' + 'keywords', 'short_desc', 'product', 'component', + 'alias', 'status_whiteboard', 'bug_status', 'resolution', + 'priority', 'assigned_to', 'bug_type' ); my $fields = join(', ', ("?") x @fields); diff --git a/Bugzilla/Elastic/Search.pm b/Bugzilla/Elastic/Search.pm index 449dc7437..c4b3109b5 100644 --- a/Bugzilla/Elastic/Search.pm +++ b/Bugzilla/Elastic/Search.pm @@ -37,7 +37,7 @@ my @SUPPORTED_FIELDS = qw( bug_id bug_type product component short_desc priority status_whiteboard bug_status resolution keywords alias assigned_to reporter delta_ts - longdesc cf_crash_signature classification bug_severity + longdesc classification bug_severity commenter ); my %IS_SUPPORTED_FIELD = map { $_ => 1 } @SUPPORTED_FIELDS; diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm index 2d998d6b4..2fc50193a 100644 --- a/Bugzilla/Search/Quicksearch.pm +++ b/Bugzilla/Search/Quicksearch.pm @@ -641,9 +641,6 @@ sub _default_quicksearch_word { if $longdesc_initial || $ELASTIC; addChart('content', 'matches', _matches_phrase($word), $negate) if $fulltext && !$ELASTIC; - -# BMO Bug 664124 - Include the crash signature (sig:) field in default quicksearches - addChart('cf_crash_signature', 'substring', $word, $negate); } sub _handle_urls { diff --git a/extensions/BMO/web/styles/bug_modal.css b/extensions/BMO/web/styles/bug_modal.css index 6f481d889..def5bbc98 100644 --- a/extensions/BMO/web/styles/bug_modal.css +++ b/extensions/BMO/web/styles/bug_modal.css @@ -5,12 +5,6 @@ * This Source Code Form is "Incompatible With Secondary Licenses", as * defined by the Mozilla Public License, v. 2.0. */ -#cf_crash_signature { - width: 100%; - height: 6em; - font-size: var(--font-size-medium); -} - #legal_disclaimer { margin: 16px 0; border: 1px solid var(--warning-message-border-color); diff --git a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl index de0ccb1f6..ef852de8a 100644 --- a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl +++ b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl @@ -1180,7 +1180,6 @@ [% FOREACH field IN custom_fields; NEXT IF field.type != constants.FIELD_TYPE_TEXTAREA; - NEXT IF field.name == "cf_crash_signature"; # Rendered below Hook.process('custom_field-' _ field.name); NEXT IF rendered_custom_fields.exists(field.name); INCLUDE bug_modal/field.html.tmpl @@ -1191,16 +1190,6 @@ %] [% END %] -[%# === Crash === %] - -[% WRAPPER bug_modal/module.html.tmpl - title = "Crash Data" - collapsed = 1 - hide_on_view = bug.cf_crash_signature == "" -%] - [% Hook.process('custom_field-cf_crash_signature'); %] -[% END %] - [%# === groups === %] [% WRAPPER bug_modal/module.html.tmpl diff --git a/js/create_bug.js b/js/create_bug.js index 3716f2aef..0e3daeab5 100644 --- a/js/create_bug.js +++ b/js/create_bug.js @@ -54,9 +54,6 @@ YAHOO.util.Event.onDOMReady(function() { el = document.getElementById('comment'); el.style.width = width; - el = document.getElementById('cf_crash_signature'); - if (el) el.style.width = width; - // show the bug flags if a flag is set var flag_set = false; diff --git a/scripts/remove-non-public-data.pl b/scripts/remove-non-public-data.pl index de5b9270d..d6d0ee93f 100755 --- a/scripts/remove-non-public-data.pl +++ b/scripts/remove-non-public-data.pl @@ -53,7 +53,7 @@ my %whitelist = ( rep_platform reporter version component_id resolution target_milestone qa_contact status_whiteboard everconfirmed estimated_time remaining_time deadline alias cf_rank - cf_crash_signature cf_last_resolved cf_user_story votes + cf_last_resolved cf_user_story votes ) ], bugs_activity => [ diff --git a/scripts/update-crash-signatures.pl b/scripts/update-crash-signatures.pl deleted file mode 100755 index e5b13d72e..000000000 --- a/scripts/update-crash-signatures.pl +++ /dev/null @@ -1,206 +0,0 @@ -#!/usr/bin/env perl - -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -use strict; -use warnings; -use lib qw(. lib local/lib/perl5); -$| = 1; - - -use constant BATCH_SIZE => 100; - -use Bugzilla; -use Bugzilla::Bug; -use Bugzilla::Constants; -use Bugzilla::Util qw( trim ); -use List::MoreUtils qw( any ); -use Text::Balanced qw( extract_bracketed extract_multiple ); - -Bugzilla->usage_mode(USAGE_MODE_CMDLINE); - -my $user = Bugzilla::User->check({name => 'automation@bmo.tld'}); -$user->{groups} = [Bugzilla::Group->get_all]; -$user->{bless_groups} = [Bugzilla::Group->get_all]; -Bugzilla->set_user($user); - -my $dbh = Bugzilla->dbh; - -# find the bugs - -my $bugs = $dbh->selectall_arrayref( - "SELECT bug_id,cf_crash_signature FROM bugs WHERE resolution = '' AND cf_crash_signature != ''", - {Slice => {}} -); -my $count = scalar @$bugs; - -# update - -die "No bugs found\n" unless $count; -print - "Found $count open bug(s) with crash signatures\nPress to stop or to continue..\n"; -getc(); - -my $updated = 0; -foreach my $rh_bug (@$bugs) { - my $bug_id = $rh_bug->{bug_id}; - my $signature = $rh_bug->{cf_crash_signature}; - - # check for updated signature - my $collapsed = collapse($signature); - next if is_same($signature, $collapsed); - - # ignore signatures malformed in a way that would result in updating on each pass - next if $collapsed ne collapse($collapsed); - - # update the bug, preventing bugmail - print "$bug_id\n"; - $dbh->bz_start_transaction; - my $bug = Bugzilla::Bug->check($bug_id); - $bug->set_all({cf_crash_signature => $collapsed}); - $bug->update(); - $dbh->do("UPDATE bugs SET lastdiffed = delta_ts WHERE bug_id = ?", - undef, $bug_id); - $dbh->bz_commit_transaction; - - # object caching causes us to consume a lot of memory - # process in batches - last if ++$updated == BATCH_SIZE; -} -print "Updated $updated bugs(s)\n"; - -sub is_same { - my ($old, $new) = @_; - $old =~ s/[\015\012]+/ /g; - $new =~ s/[\015\012]+/ /g; - return trim($old) eq trim($new); -} - -sub collapse { - my ($crash_signature) = @_; - - # ignore completely invalid signatures - return $crash_signature - unless $crash_signature =~ /\[/ && $crash_signature =~ /\]/; - - # split - my @signatures = grep {/\S/} - extract_multiple($crash_signature, [sub { extract_bracketed($_[0], '[]') }]); - my @unbracketed = map { unbracketed($_) } @signatures; - - foreach my $signature (@signatures) { - - # ignore invalid signatures - next unless $signature =~ /^\s*\[/; - next if unbracketed($signature) =~ /\.\.\.$/; - - # collpase - my $collapsed = collapse_crash_sig({ - signature => $signature, - open => '<', - replacement_open => '<', - close => '>', - replacement_close => 'T>', - exceptions => [], - }); - $collapsed = collapse_crash_sig({ - signature => $collapsed, - open => '(', - replacement_open => '', - close => ')', - replacement_close => '', - exceptions => ['anonymous namespace', 'operator'], - }); - $collapsed =~ s/\s+/ /g; - - # ignore sigs that collapse down to nothing - next if $collapsed eq '[@ ]'; - - # don't create duplicates - my $unbracketed = unbracketed($collapsed); - next if any { $unbracketed eq $_ } @unbracketed; - - push @signatures, $collapsed; - push @unbracketed, $unbracketed; - } - - return join("\015\012", map { trim($_) } @signatures); -} - -sub unbracketed { - my ($signature) = @_; - $signature =~ s/(^\s*\[\s*|\s*\]\s*$)//g; - return $signature; -} - -# collapsing code lifted from socorro: -# https://github.com/mozilla/socorro/blob/master/socorro/processor/signature_utilities.py#L110 - -my ($target_counter, $exception_mode, @collapsed); - -sub append_if_not_in_collapse_mode { - my ($character) = @_; - if (!$target_counter) { - push @collapsed, $character; - } -} - -sub is_exception { - my ($exceptions, $remaining_original_line, $line_up_to_current_position) = @_; - foreach my $exception (@$exceptions) { - if (substr($remaining_original_line, 0, length($exception)) eq $exception) { - return 1; - } - if (substr($line_up_to_current_position, -length($exception)) eq $exception) { - return 1; - } - } - return 0; -} - -sub collapse_crash_sig { - my ($params) = @_; - - $target_counter = 0; - @collapsed = (); - $exception_mode = 0; - my $signature = $params->{signature}; - - for (my $i = 0; $i < length($signature); $i++) { - my $character = substr($signature, $i, 1); - if ($character eq $params->{open}) { - if (is_exception( - $params->{exceptions}, - substr($signature, $i + 1), - substr($signature, 0, $i) - )) - { - $exception_mode = 1; - append_if_not_in_collapse_mode($character); - next; - } - append_if_not_in_collapse_mode($params->{replacement_open}); - $target_counter++; - } - elsif ($character eq $params->{close}) { - if ($exception_mode) { - append_if_not_in_collapse_mode($character); - $exception_mode = 0; - } - else { - $target_counter--; - append_if_not_in_collapse_mode($params->{replacement_close}); - } - } - else { - append_if_not_in_collapse_mode($character); - } - } - - return join '', @collapsed; -} diff --git a/skins/standard/show_bug.css b/skins/standard/show_bug.css index f5105e52f..d98439769 100644 --- a/skins/standard/show_bug.css +++ b/skins/standard/show_bug.css @@ -95,10 +95,6 @@ table.edit_form hr { margin-right: 10px; } -#cf_crash_signature { - width: 100%; -} - #bz_ctag_error { border: none; padding: 2px 6px; diff --git a/template/en/default/bug/create/create.html.tmpl b/template/en/default/bug/create/create.html.tmpl index 0bd6abbc6..537a5d5a4 100644 --- a/template/en/default/bug/create/create.html.tmpl +++ b/template/en/default/bug/create/create.html.tmpl @@ -56,7 +56,6 @@ function init() { hideElementById('attachment_true'); showElementById('attachment_false'); showElementById('btn_no_attachment'); - initCrashSignatureField(); init_take_handler('[% user.login FILTER js %]'); bz_attachment_form.update_requirements(false); @@ -69,17 +68,6 @@ function init() { }, { once: true }); } -function initCrashSignatureField() { - var el = document.getElementById('cf_crash_signature'); - if (!el) return; - [% IF cf_crash_signature.length %] - YAHOO.util.Dom.addClass('cf_crash_signature_container', 'bz_default_hidden'); - [% ELSE %] - hideEditableField('cf_crash_signature_container','cf_crash_signature_input', - 'cf_crash_signature_action', 'cf_crash_signature'); - [% END %] -} - const params = new URLSearchParams(location.search); let bug_type_specified = params.has('bug_type') || params.has('cloned_bug_id') || params.has('regressed_by'); let desc_edited = false;