From: Kohei Yoshino Date: Tue, 2 Apr 2019 19:27:45 +0000 (-0400) Subject: Bug 1531757 - Allow to search only in bug description (comment 0) with both Quick... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6210b412173a0ac9015a21f47041db6f306e42a7;p=thirdparty%2Fbugzilla.git Bug 1531757 - Allow to search only in bug description (comment 0) with both Quick and Advenced Search as well as API --- diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index c61f448e7..a3f929011 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -2667,6 +2667,12 @@ sub _long_desc_nonchanged { }; $self->_do_operator_function($join_args); + # Allow to search only in bug description (initial comment) + if ($self->_params->{longdesc_initial}) { + $join_args->{term} + .= ($join_args->{term} ? " AND " : "") . "$table.bug_when = bugs.creation_ts"; + } + # If the user is not part of the insiders group, they cannot see # private comments if (!$self->_user->is_insider) { diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm index c8317a100..335caedbb 100644 --- a/Bugzilla/Search/Quicksearch.pm +++ b/Bugzilla/Search/Quicksearch.pm @@ -131,7 +131,8 @@ use constant COMPONENT_EXCEPTIONS => ( ); # Quicksearch-wide globals for boolean charts. -our ($chart, $and, $or, $fulltext, $bug_status_set, $bug_product_set, $ELASTIC); +our ($chart, $and, $or, $longdesc_initial, $fulltext, $bug_status_set, + $bug_product_set, $ELASTIC); sub quicksearch { my ($searchstring) = (@_); @@ -199,6 +200,12 @@ sub quicksearch { unshift(@words, "-$word"); } + # --description and ++description disable or enable description searching + elsif ($word =~ /^(--|\+\+)description?$/i) { + $longdesc_initial = $1 eq '--' ? 0 : 1; + $cgi->param('longdesc_initial', $longdesc_initial); + } + # --comment and ++comment disable or enable fulltext searching elsif ($word =~ /^(--|\+\+)comments?$/i) { $fulltext = $1 eq '--' ? 0 : 1; @@ -410,6 +417,8 @@ sub _handle_special_first_chars { if ($firstChar eq '#') { addChart('short_desc', 'substring', $baseWord, $negate); + addChart('longdesc', 'substring', $baseWord, $negate) + if $longdesc_initial; addChart('content', 'matches', _matches_phrase($baseWord), $negate) if $fulltext; return 1; @@ -628,7 +637,8 @@ sub _default_quicksearch_word { addChart('alias', 'substring', $word, $negate); addChart('short_desc', 'substring', $word, $negate); addChart('status_whiteboard', 'substring', $word, $negate); - addChart('longdesc', 'substring', $word, $negate) if $ELASTIC; + addChart('longdesc', 'substring', $word, $negate) + if $longdesc_initial || $ELASTIC; addChart('content', 'matches', _matches_phrase($word), $negate) if $fulltext && !$ELASTIC; diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index bbfbe6360..cae4efde7 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -551,6 +551,12 @@ sub search { delete $match_params->{offset}; } + # Allow to search only in bug description (initial comment) + if (defined $match_params->{description}) { + $match_params->{longdesc} = delete $match_params->{description}; + $match_params->{longdesc_initial} = 1; + } + $match_params = Bugzilla::Bug::map_fields($match_params); my %options = (fields => ['bug_id']); @@ -1475,6 +1481,12 @@ sub _bug_to_hash { my @depends_on = map { $self->type('int', $_) } @{$bug->dependson}; $item{'depends_on'} = \@depends_on; } + if (filter_wants $params, 'description', ['extra']) { + my $comment = Bugzilla::Comment->match({bug_id => $bug->id, LIMIT => 1})->[0]; + $item{'description'} + = ($comment && (!$comment->is_private || Bugzilla->user->is_insider)) + ? $comment->body : ''; + } if (filter_wants $params, 'dupe_of') { $item{'dupe_of'} = $self->type('int', $bug->dup_id); } @@ -2766,6 +2778,13 @@ in the return value. C of Cs. The ids of bugs that this bug "depends on". +=item C + +C The description (initial comment) of the bug. + +This is an B field returned only by specifying C or +C<_extra> in C. + =item C C The bug ID of the bug that this bug is a duplicate of. If this bug @@ -3132,9 +3151,9 @@ and all custom fields. =item The C item was added to the C return value in Bugzilla B<4.4>. -=item The C, C, C, C, -C, C, C and C fields were added -in Bugzilla B<6.0>. +=item The C, C, C, C, +C, C, C, C and C fields +were added in Bugzilla B<6.0>. =back @@ -3401,6 +3420,10 @@ C The login name of the user who created the bug. You can also pass this argument with the name C, for backwards compatibility with older Bugzillas. +=item C + +C The description (initial comment) of the bug. + =item C C The numeric id of the bug. @@ -3557,6 +3580,8 @@ in Bugzilla B<5.0>. =item Updated to allow quicksearch capability in Bugzilla B<5.0>. +=item The C field was added in Bugzilla B<6.0>. + =back =back @@ -3625,8 +3650,8 @@ filed. =item C (string) B - A version of the product above; the version the bug was found in. -=item C (string) B - The initial description for -this bug. Some Bugzilla installations require this to not be blank. +=item C (string) B - The description (initial comment) +of the bug. Some Bugzilla installations require this to not be blank. =item C (string) B - The operating system the bug was discovered on. diff --git a/docs/en/rst/api/core/v1/bug.rst b/docs/en/rst/api/core/v1/bug.rst index cead3697e..6fe94ddcf 100644 --- a/docs/en/rst/api/core/v1/bug.rst +++ b/docs/en/rst/api/core/v1/bug.rst @@ -256,6 +256,7 @@ attachments array Each array item is an Attachment object. See :ref:`rest_attachments` for details of the object. comments array Each array item is a Comment object. See :ref:`rest_comments` for details of the object. +description string The description (initial comment) of the bug. history array Each array item is a History object. See :ref:`rest_history` for details of the object. tags array Each array item is a tag name. Note that tags are @@ -497,6 +498,7 @@ creator string The login name of the user who created the bug. You can also pass this argument with the name ``reporter``, for backwards compatibility with older Bugzillas. +description string The description (initial comment) of the bug. id int The numeric ID of the bug. last_change_time datetime Searches for bugs that were modified at this time or later. May not be an array. @@ -635,9 +637,9 @@ name type description **summary** string A brief description of the bug being filed. **version** string A version of the product above; the version the bug was found in. -description string (defaulted) The initial description for this bug. - Some Bugzilla installations require this to not be - blank. +description string (defaulted) The description (initial comment) of the + bug. Some Bugzilla installations require this to not + be blank. op_sys string (defaulted) The operating system the bug was discovered on. platform string (defaulted) What type of hardware the bug was diff --git a/template/en/default/pages/quicksearch.html.tmpl b/template/en/default/pages/quicksearch.html.tmpl index 38fb9c004..d5417e761 100644 --- a/template/en/default/pages/quicksearch.html.tmpl +++ b/template/en/default/pages/quicksearch.html.tmpl @@ -366,8 +366,10 @@ Comment Searching Allows overriding of the comment searching preference.
- "++comments" will always enable comment searching.
- "--comments" will always disable searching.
+ "++comments" enables full-text search (all comments, slow)
+ "--comments" disables full-text search
+ "++description" enables description search (initial comment only)
+ "--description" disables description search
[% IF Param('usestatuswhiteboard') %] diff --git a/template/en/default/search/form.html.tmpl b/template/en/default/search/form.html.tmpl index 54d297d50..33c6f1f23 100644 --- a/template/en/default/search/form.html.tmpl +++ b/template/en/default/search/form.html.tmpl @@ -233,6 +233,10 @@ TUI_hide_default('information_query'); value => default.${field_container.field.name}.0 type_selected => default.$type.0 %] + [% IF field_container.field.name == 'longdesc' %] + + [% END %] [% END %]