[Rt-commit] rt branch, 4.2/asset-bulk-cf, created. rt-4.2.13-74-g0cf934d

Shawn Moore shawn at bestpractical.com
Thu Dec 29 13:54:14 EST 2016


The branch, 4.2/asset-bulk-cf has been created
        at  0cf934de1da1cea2433c9da3946357bda9c16c7f (commit)

- Log -----------------------------------------------------------------
commit 0cf934de1da1cea2433c9da3946357bda9c16c7f
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Thu Dec 29 18:43:55 2016 +0000

    Fix bulk update for asset CFs
    
    e6c84c1098d5940ab45a683d1f4197f9e57e7e5f added support for bulk update's
    parameter naming convention in order to implement autocomplete CFs on
    bulk update. However this change inadvertently broke bulk update of asset CFs
    (both in the extension for 4.2 and in core 4.4). Introducing the bulk update
    parameter naming convention to ProcessObjectCustomFieldUpdates caused it
    to throw errors, as it is not prepared to handle empty $class names.
    
    Since the only caller that needs to handle the bulk update parameter
    naming convention is /Helpers/Autocomplete/CustomFieldValues (to parse
    the current custom field value out of the form parameters in order to
    provide autocomplete suggestions, which was exactly the driver behind
    the change in the above commit that introduced the breakage), limiting
    _ParseObjectCustomFieldArgs to including the bulk update naming
    convention if and only if requested (with the new IncludeBulkUpdate
    parameter) maintains the bulk autocomplete feature while restoring asset
    CF bulk update.
    
    The loathsome empty capture groups are required because the regular
    expression was split into two, made conditional upon the IncludeBulkUpdate
    parameter. In the previous factoring of the code, those two capture groups
    were in the /^Object-/ branch of the regular expression, so $1 and $2
    were empty in the /^Bulk-/ branch.
    
    Fixes: I#32509

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index cbf10d2..9900bb0 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -3118,14 +3118,21 @@ sub ProcessObjectCustomFieldUpdates {
 
 sub _ParseObjectCustomFieldArgs {
     my $ARGSRef = shift || {};
+    my %args = (
+        IncludeBulkUpdate => 0,
+        @_,
+    );
     my %custom_fields_to_mod;
 
     foreach my $arg ( keys %$ARGSRef ) {
 
         # format: Object-<object class>-<object id>-CustomField[:<grouping>]-<CF id>-<commands>
-        # or: Bulk-<Add or Delete>-CustomField[:<grouping>]-<CF id>-<commands>
         # you can use GetCustomFieldInputName to generate the complement input name
-        next unless $arg =~ /^(?:Bulk-(?:Add|Delete)|Object-([\w:]+)-(\d*))-CustomField(?::(\w+))?-(\d+)-(.*)$/;
+        # or if IncludeBulkUpdate: Bulk-<Add or Delete>-CustomField[:<grouping>]-<CF id>-<commands>
+        next unless $arg =~ /^Object-([\w:]+)-(\d*)-CustomField(?::(\w+))?-(\d+)-(.*)$/
+                 || ($args{IncludeBulkUpdate} && $arg =~ /^Bulk-(?:Add|Delete)-()()CustomField(?::(\w+))?-(\d+)-(.*)$/);
+        # need two empty groups because we must consume $1 and $2 with empty
+        # class and ID
 
         # For each of those objects, find out what custom fields we want to work with.
         #                   Class     ID     CF  grouping command
diff --git a/share/html/Helpers/Autocomplete/CustomFieldValues b/share/html/Helpers/Autocomplete/CustomFieldValues
index 6c822b1..6dae844 100644
--- a/share/html/Helpers/Autocomplete/CustomFieldValues
+++ b/share/html/Helpers/Autocomplete/CustomFieldValues
@@ -68,7 +68,7 @@ unless ( exists $ARGS{ContextType} and exists $ARGS{ContextId} ) {
 # structure returned. There will be only one CF, so drill down 2 layers
 # to get the cf id, if one is there.
 
-my %custom_fields = _ParseObjectCustomFieldArgs(\%ARGS);
+my %custom_fields = _ParseObjectCustomFieldArgs(\%ARGS, IncludeBulkUpdate => 1);
 my $CustomField;
 foreach my $class ( keys %custom_fields ){
     foreach my $id ( keys %{$custom_fields{$class}} ){

-----------------------------------------------------------------------


More information about the rt-commit mailing list