[Rt-commit] rt branch, 4.2/fix-organization-for-all-links, created. rt-4.2.3-8-ga8d66ca

Jim Brandt jbrandt at bestpractical.com
Tue Feb 25 15:32:24 EST 2014


The branch, 4.2/fix-organization-for-all-links has been created
        at  a8d66ca118a7707e6557d9c7ade42d792e87d08d (commit)

- Log -----------------------------------------------------------------
commit a8d66ca118a7707e6557d9c7ade42d792e87d08d
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Feb 25 15:23:04 2014 -0500

    Validate article and other types of links
    
    Check non-ticket links for a changed Organization and
    for links to missing objects like Articles. Use %INC
    to find loaded RT::URI subclasses to catch link types that
    might be loaded from an extension like Assets.
    
    Add Article to the models checked since Articles are part of
    RT now.
    
    Didn't indent inside the added foreach loops because the code
    is already heavily indented. Commented the end curly-brace
    to make it easier to see.

diff --git a/sbin/rt-validator.in b/sbin/rt-validator.in
old mode 100644
new mode 100755
index db89dce..33a8ef3
--- a/sbin/rt-validator.in
+++ b/sbin/rt-validator.in
@@ -115,6 +115,7 @@ my %TYPE = (
 
 my @models = qw(
     ACE
+    Article
     Attachment
     Attribute
     CachedGroupMember
@@ -930,7 +931,10 @@ push @CHECKS, 'Links: wrong organization' => sub {
         { model => 'Link', column => 'Base' },
     );
 
-    my $rt_uri = RT::URI::fsck_com_rt->new( $RT::SystemUser );
+    my @rt_uris = rt_uri_modules();
+    foreach my $package (@rt_uris) {
+
+    my $rt_uri = $package->new( $RT::SystemUser );
     my $scheme = $rt_uri->Scheme;
     my $prefix = $rt_uri->LocalURIPrefix;
 
@@ -972,6 +976,7 @@ push @CHECKS, 'Links: wrong organization' => sub {
             last; # plenty of chances we covered all cases with one update
         }
     }
+    } # end foreach my $package (@rt_uris)
     return $res;
 };
 
@@ -1055,7 +1060,10 @@ push @CHECKS, 'Links: missing object' => sub {
         { model => 'Link', column => 'Base' },
     );
 
-    my $rt_uri = RT::URI::fsck_com_rt->new( $RT::SystemUser );
+    my @rt_uris = rt_uri_modules();
+    foreach my $package (@rt_uris) {
+
+    my $rt_uri = $package->new( $RT::SystemUser );
     my $scheme = $rt_uri->Scheme;
     my $prefix = $rt_uri->LocalURIPrefix;
 
@@ -1096,6 +1104,7 @@ push @CHECKS, 'Links: missing object' => sub {
             }
         }
     }
+    } # end foreach my $package (@rt_uris)
     return $res;
 };
 
@@ -1375,6 +1384,20 @@ sub prompt_integer {
     return $cached_answer{ $token } = $a;
 } }
 
+# Find all RT::URI modules RT has loaded
+
+sub rt_uri_modules {
+    my @uris = grep /^RT\/URI\/.+\.pm$/, keys %INC;
+    my @uri_modules;
+    foreach my $uri_path (@uris){
+        next if $uri_path =~ /base\.pm$/; # Skip base RT::URI object
+        $uri_path = substr $uri_path, 0, -3; # chop off .pm
+        push @uri_modules, join '::', split '/', $uri_path;
+    }
+
+    return @uri_modules;
+}
+
 1;
 
 __END__

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


More information about the rt-commit mailing list