[Rt-commit] rt branch, 4.2/grouping-ordering, updated. rt-4.1.8-313-g89c728f

Alex Vandiver alexmv at bestpractical.com
Fri May 17 18:44:09 EDT 2013


The branch, 4.2/grouping-ordering has been updated
       via  89c728fa3b0d581d458f59c9b8d0c62065e59078 (commit)
      from  42561b7d73808026585b9b171ee45c8a7bfec9de (commit)

Summary of changes:
 lib/RT/CustomField.pm  | 12 ++++++++----
 lib/RT/CustomFields.pm |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit 89c728fa3b0d581d458f59c9b8d0c62065e59078
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri May 17 18:42:19 2013 -0400

    Do not assume that PostLoadCheck normalized to arrayrefs
    
    The irevious commit normalized hashrefs into sorted arrayrefs during the
    PostLoadCheck.  However, this is insufficient to cope with configuration
    settings which are altered at run-time, after PostLoadChecks have been
    run -- which include tests.  Adjust ->Groupings and ->LimitToGrouping to
    cope with hashrefs as well.

diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index 799b641..3051de0 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -1276,10 +1276,14 @@ sub Groupings {
     my @groups;
     if ( $record_class ) {
         push @groups, sort {lc($a) cmp lc($b)} keys %{ $BUILTIN_GROUPINGS{$record_class} || {} };
-        my @order = @{ $config->{$record_class} || [] };
-        while (@order) {
-            push @groups, shift(@order);
-            shift(@order);
+        if ( ref($config->{$record_class} ||= []) eq "ARRAY") {
+            my @order = @{ $config->{$record_class} };
+            while (@order) {
+                push @groups, shift(@order);
+                shift(@order);
+            }
+        } else {
+            @groups = sort {lc($a) cmp lc($b)} keys %{ $config->{$record_class} };
         }
     } else {
         my %all = (%$config, %BUILTIN_GROUPINGS);
diff --git a/lib/RT/CustomFields.pm b/lib/RT/CustomFields.pm
index 59509ab..9e35e6f 100644
--- a/lib/RT/CustomFields.pm
+++ b/lib/RT/CustomFields.pm
@@ -123,7 +123,7 @@ sub LimitToGrouping {
     my $config = RT->Config->Get('CustomFieldGroupings');
        $config = {} unless ref($config) eq 'HASH';
        $config = $config->{ref($obj) || $obj} || [];
-    my %h = @{$config};
+    my %h = ref $config eq "ARRAY" ? @{$config} : %{$config};
 
     if ( $grouping ) {
         my $list = $h{$grouping};

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


More information about the Rt-commit mailing list