LP#1205072 - Action Trigger Granularity Case Sensitivity user/stompro/lp1205072-action-trig-granularity-ui-case-insensitive
authorJosh Stompro <stomproj@larl.org>
Thu, 14 May 2015 02:11:08 +0000 (21:11 -0500)
committerJosh Stompro <stomproj@larl.org>
Thu, 14 May 2015 02:11:08 +0000 (21:11 -0500)
This change makes the granularity settings case insensitive.

To test this issue
1. Create/Modify an action trigger to have an all uppercase granularity settings.
2. Run action_trigger_runner.pl with the same granularity set to lowercase
3. Observe that the events are not processed.

After the change is applied the granularity case doesn't matter for either the event_definition
or the flag to action_trigger_runner.pl.

I didn't modify the code path for when the granularity only flag isn't set since it
never gets used, and I don't want to change what I cannot test.  Maybe the best course
of action would just be to remove that section?

Signed-off-by: Josh Stompro <stomproj@larl.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger.pm

index ed83cba..70b89a9 100644 (file)
@@ -70,7 +70,7 @@ sub create_active_events_for_object {
     );
 
     for my $def ( @$defs ) {
-        next if ($granularity && $def->granularity ne $granularity );
+        next if ($granularity && lc($def->granularity) ne lc($granularity) );
 
         if ($def->usr_field && $def->opt_in_setting) {
             my $ufield = $def->usr_field;
@@ -418,7 +418,7 @@ sub create_batch_events {
     }
 
     for my $def ( @$defs ) {
-        next if ($granularity && $def->granularity ne $granularity );
+        next if ($granularity && lc($def->granularity) ne lc($granularity) );
 
         my $date = DateTime->now->subtract( seconds => interval_to_seconds($def->delay) );
 
@@ -649,7 +649,12 @@ sub pending_events {
 
     if (defined $granularity) {
         if ($granflag) {
-            $query->[0]->{'+atevdef'} = {granularity => $granularity};
+            $query->[0]->{'+atevdef'} = {granularity => {
+              '=' => {
+                           transform => 'evergreen.lowercase',
+                               value => lc($granularity)
+                         }
+            }};
         } else {
             $query->[0]->{'+atevdef'} = {'-or' => [ {granularity => $granularity}, {granularity => undef} ] };
         }