[Bps-public-commit] rt-extension-automaticassignment branch move-to-module-runtime updated. 1.00-2-g51d021c

BPS Git Server git at git.bestpractical.com
Tue Aug 1 16:33:40 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt-extension-automaticassignment".

The branch, move-to-module-runtime has been updated
       via  51d021cc653a64ce720f1522078d78e0d30946bd (commit)
      from  66c5f98984587fea975b051fedf2f2d7d5fff5f1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 51d021cc653a64ce720f1522078d78e0d30946bd
Author: Brad Embree <brad at bestpractical.com>
Date:   Tue Aug 1 09:29:48 2023 -0700

    Fix require module logic for old RT versions
    
    The new RT::StaticUtil::RequireModule method that uses Module::Runtime
    is not available for RT versions before 5.0.4.
    
    This fix allows the extension to work with older versions without the
    RT::StaticUtil::RequireModule method.

diff --git a/html/Admin/Queues/AutomaticAssignment.html b/html/Admin/Queues/AutomaticAssignment.html
index 060765e..7a0d823 100644
--- a/html/Admin/Queues/AutomaticAssignment.html
+++ b/html/Admin/Queues/AutomaticAssignment.html
@@ -16,10 +16,17 @@
 
 % for my $filter (@filters) {
 % my $class = "RT::Extension::AutomaticAssignment::Filter::$filter";
-% my ($ok, $msg) = RT::StaticUtil::RequireModule( $class );
-% unless ( $ok ) {
-%     RT->Logger->error("Couldn't load class '$class': $msg");
-%     $m->abort;
+% if ( RT::Handle::cmp_version($RT::VERSION, '5.0.4') >= 0 ) {
+%     my ($ok, $msg) = RT::StaticUtil::RequireModule( $class );
+%     unless ( $ok ) {
+%         RT->Logger->error("Couldn't load class '$class': $msg");
+%         $m->abort;
+%     }
+% } else {
+%     unless ($class->require) {
+%         RT->Logger->error("Couldn't load class '$class': $@");
+%         $m->abort;
+%     }
 % }
 <option value="<% $filter %>"><% $class->Description %></option>
 % }
@@ -66,10 +73,17 @@
 
 % for my $chooser (@choosers) {
 % my $class = "RT::Extension::AutomaticAssignment::Chooser::$chooser";
-% my ($ok, $msg) = RT::StaticUtil::RequireModule( $class );
-% unless ( $ok ) {
-%     RT->Logger->error("Couldn't load class '$class': $msg");
-%     $m->abort;
+% if ( RT::Handle::cmp_version($RT::VERSION, '5.0.4') >= 0 ) {
+%     my ($ok, $msg) = RT::StaticUtil::RequireModule( $class );
+%     unless ( $ok ) {
+%         RT->Logger->error("Couldn't load class '$class': $msg");
+%         $m->abort;
+%     }
+% } else {
+%     unless ($class->require) {
+%         RT->Logger->error("Couldn't load class '$class': $@");
+%         $m->abort;
+%     }
 % }
 <option <% $name eq $chooser ? "selected" : "" %> value="<% $chooser %>"><% $class->Description %></option>
 % }
diff --git a/html/Admin/Queues/Elements/SortableBox b/html/Admin/Queues/Elements/SortableBox
index 32a0d24..c2e66c7 100644
--- a/html/Admin/Queues/Elements/SortableBox
+++ b/html/Admin/Queues/Elements/SortableBox
@@ -16,11 +16,17 @@ if ($is_filter) {
 else {
     $class = "RT::Extension::AutomaticAssignment::Chooser::$class_name";
 }
-
-my ($ok, $msg) = RT::StaticUtil::RequireModule( $class );
-unless ( $ok ) {
-    RT->Logger->error("Couldn't load class '$class': $msg");
-    $m->abort;
+if ( RT::Handle::cmp_version($RT::VERSION, '5.0.4') >= 0 ) {
+    my ($ok, $msg) = RT::StaticUtil::RequireModule( $class );
+    unless ( $ok ) {
+        RT->Logger->error("Couldn't load class '$class': $msg");
+        $m->abort;
+    }
+} else {
+    unless ($class->require) {
+        RT->Logger->error("Couldn't load class '$class': $@");
+        $m->abort;
+    }
 }
 
 my $title_right
diff --git a/lib/RT/Extension/AutomaticAssignment.pm b/lib/RT/Extension/AutomaticAssignment.pm
index 7f0c2d7..05ecf24 100644
--- a/lib/RT/Extension/AutomaticAssignment.pm
+++ b/lib/RT/Extension/AutomaticAssignment.pm
@@ -16,8 +16,12 @@ sub _LoadedClass {
     my $name      = shift;
 
     my $class = "RT::Extension::AutomaticAssignment::${namespace}::$name";
-    my ($ok, $msg) = RT::StaticUtil::RequireModule( $class );
-    die $msg unless $ok;
+    if ( RT::Handle::cmp_version($RT::VERSION, '5.0.4') >= 0 ) {
+        my ($ok, $msg) = RT::StaticUtil::RequireModule( $class );
+        die $msg unless $ok;
+    } else {
+        $class->require or die $UNIVERSAL::require::ERROR;
+    }
     return $class;
 }
 
@@ -143,10 +147,17 @@ sub _SetConfigForQueue {
         next unless grep { $_ eq $name } RT->Config->Get('AutomaticAssignmentFilters');
 
         my $class = "RT::Extension::AutomaticAssignment::Filter::$name";
-        my ($ok, $msg) = RT::StaticUtil::RequireModule( $class );
-        unless ( $ok ) {
-            RT->Logger->error("Couldn't load class '$class': $msg");
-            return (0, "Couldn't load class '$class'");
+        if ( RT::Handle::cmp_version($RT::VERSION, '5.0.4') >= 0 ) {
+            my ($ok, $msg) = RT::StaticUtil::RequireModule( $class );
+            unless ( $ok ) {
+                RT->Logger->error("Couldn't load class '$class': $msg");
+                return (0, "Couldn't load class '$class'");
+            }
+        } else {
+            unless ($class->require) {
+                RT->Logger->error("Couldn't load class '$class': $@");
+                return (0, "Couldn't load class '$class'");
+            }
         }
 
         my $config = $class->CanonicalizeConfig($filter);
@@ -161,10 +172,17 @@ sub _SetConfigForQueue {
         next unless grep { $_ eq $name } RT->Config->Get('AutomaticAssignmentChoosers');
 
         my $class = "RT::Extension::AutomaticAssignment::Chooser::$name";
-        my ($ok, $msg) = RT::StaticUtil::RequireModule( $class );
-        unless ( $ok ) {
-            RT->Logger->error("Couldn't load class '$class': $msg");
-            return (0, "Couldn't load class '$class'");
+        if ( RT::Handle::cmp_version($RT::VERSION, '5.0.4') >= 0 ) {
+            my ($ok, $msg) = RT::StaticUtil::RequireModule( $class );
+            unless ( $ok ) {
+                RT->Logger->error("Couldn't load class '$class': $msg");
+                return (0, "Couldn't load class '$class'");
+            }
+        } else {
+            unless ($class->require) {
+                RT->Logger->error("Couldn't load class '$class': $@");
+                return (0, "Couldn't load class '$class'");
+            }
         }
 
         $config{chooser} = $class->CanonicalizeConfig($chooser);

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

Summary of changes:
 html/Admin/Queues/AutomaticAssignment.html | 30 ++++++++++++++++-------
 html/Admin/Queues/Elements/SortableBox     | 16 +++++++++----
 lib/RT/Extension/AutomaticAssignment.pm    | 38 ++++++++++++++++++++++--------
 3 files changed, 61 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
rt-extension-automaticassignment


More information about the Bps-public-commit mailing list