[Rt-commit] rt branch, 4.4/siteconfig.d, created. rt-4.2.3-205-gf5d0dd2

? sunnavy sunnavy at bestpractical.com
Fri Jul 18 07:59:26 EDT 2014


The branch, 4.4/siteconfig.d has been created
        at  f5d0dd21df0f15853bbdecf3250b4b5f988497c1 (commit)

- Log -----------------------------------------------------------------
commit b9e9f324434af878e114115aebe1c492e91e91ca
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jun 27 18:51:26 2014 +0800

    typo

diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 40dcec1..6c88775 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -88,7 +88,7 @@ Second file is F<RT_SiteConfig.pm> - site config file. You can use it
 to customize your RT instance. In this file you can override any option
 listed in core config file.
 
-RT extensions could also provide thier config files. Extensions should
+RT extensions could also provide their config files. Extensions should
 use F<< <NAME>_Config.pm >> and F<< <NAME>_SiteConfig.pm >> names for
 config files, where <NAME> is extension name.
 

commit 338ef65cb7eb0bc4831394349416f461cf5eea56
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jun 27 00:16:39 2014 +0800

    support config files in RT_SiteConfig.d

diff --git a/Makefile.in b/Makefile.in
index 3f90def..f704f5c 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -454,6 +454,7 @@ doc-install:
 
 etc-install:
 @COMMENT_INPLACE_LAYOUT@	[ -d $(DESTDIR)$(RT_ETC_PATH) ] || $(INSTALL) -m 0755 -d $(DESTDIR)$(RT_ETC_PATH)
+ at COMMENT_INPLACE_LAYOUT@	[ -d "$(DESTDIR)$(RT_ETC_PATH)/RT_SiteConfig.d" ] || $(INSTALL) -m 0755 -d "$(DESTDIR)$(RT_ETC_PATH)/RT_SiteConfig.d"
 @COMMENT_INPLACE_LAYOUT@	for file in $(ETC_FILES) ; do \
 @COMMENT_INPLACE_LAYOUT@	    $(INSTALL) -m 0644 "etc/$$file" "$(DESTDIR)$(RT_ETC_PATH)/" ; \
 @COMMENT_INPLACE_LAYOUT@	done
diff --git a/docs/UPGRADING-4.4 b/docs/UPGRADING-4.4
index 85f2aa2..4c8c90a 100644
--- a/docs/UPGRADING-4.4
+++ b/docs/UPGRADING-4.4
@@ -14,6 +14,12 @@ before you upgrade and look for changes to features you currently use.
 The support for C<jsmin> (via the C<$JSMinPath> configuration) has been
 removed in favor of a built-in solution.
 
+=item *
+
+You can now split settings from F<RT_SiteConfig.pm> into separate files under
+an F<etc/RT_SiteConfig.d/> directory. All files ending in C<.pm> will be
+parsed, in alphabetical order, after the main F<RT_SiteConfig.pm> is loaded.
+
 =back
 
 =cut
diff --git a/etc/RT_SiteConfig.pm b/etc/RT_SiteConfig.pm
index 683f2b7..c2df501 100755
--- a/etc/RT_SiteConfig.pm
+++ b/etc/RT_SiteConfig.pm
@@ -15,6 +15,11 @@
 #   perl -c /path/to/your/etc/RT_SiteConfig.pm
 #
 # You must restart your webserver after making changes to this file.
+#
+
+# You may also split settings into separate files under the etc/RT_SiteConfig.d/
+# directory.  All files ending in ".pm" will be parsed, in alphabetical order,
+# after this file is loaded.
 
 Set( $rtname, 'example.com');
 
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 6c88775..5fb16e9 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -88,6 +88,10 @@ Second file is F<RT_SiteConfig.pm> - site config file. You can use it
 to customize your RT instance. In this file you can override any option
 listed in core config file.
 
+You may also split settings into separate files under the
+F<etc/RT_SiteConfig.d/> directory.  All files ending in C<.pm> will be parsed,
+in alphabetical order, after F<RT_SiteConfig.pm> is loaded.
+
 RT extensions could also provide their config files. Extensions should
 use F<< <NAME>_Config.pm >> and F<< <NAME>_SiteConfig.pm >> names for
 config files, where <NAME> is extension name.
@@ -1015,13 +1019,19 @@ sub LoadConfig {
     my $self = shift;
     my %args = ( File => '', @_ );
     $args{'File'} =~ s/(?<!Site)(?=Config\.pm$)/Site/;
-    if ( $args{'File'} eq 'RT_SiteConfig.pm'
-        and my $site_config = $ENV{RT_SITE_CONFIG} )
-    {
-        $self->_LoadConfig( %args, File => $site_config );
+    if ( $args{'File'} eq 'RT_SiteConfig.pm' ) {
+        my $load = $ENV{RT_SITE_CONFIG} || $args{'File'};
+        $self->_LoadConfig( %args, File => $load );
         # to allow load siteconfig again and again in case it's updated
-        delete $INC{ $site_config };
-    } else {
+        delete $INC{$load};
+
+        my $dir = $ENV{RT_SITE_CONFIG_DIR} || "$RT::EtcPath/RT_SiteConfig.d";
+        for my $file ( sort <$dir/*.pm> ) {
+            $self->_LoadConfig( %args, File => $file, Site => 1, Extension => '' );
+            delete $INC{$file};
+        }
+    }
+    else {
         $self->_LoadConfig(%args);
         delete $INC{$args{'File'}};
     }
@@ -1036,7 +1046,11 @@ sub _LoadConfig {
     my %args = ( File => '', @_ );
 
     my ($is_ext, $is_site);
-    if ( $args{'File'} eq ($ENV{RT_SITE_CONFIG}||'') ) {
+    if ( defined $args{Site} && defined $args{Extension} ) {
+        $is_ext = $args{Extension};
+        $is_site = $args{Site};
+    }
+    elsif ( $args{'File'} eq ($ENV{RT_SITE_CONFIG}||'') ) {
         ($is_ext, $is_site) = ('', 1);
     } else {
         $is_ext = $args{'File'} =~ /^(?!RT_)(?:(.*)_)(?:Site)?Config/ ? $1 : '';

commit f5d0dd21df0f15853bbdecf3250b4b5f988497c1
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Jul 18 19:57:24 2014 +0800

    no need to append "1;" to config files any more
    
    it makes writing config files a bit more easily.

diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 5fb16e9..f996024 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -1089,7 +1089,10 @@ sub _LoadConfig {
         push @etc_dirs, RT->PluginDirs('etc') if $is_ext;
         push @etc_dirs, $RT::EtcPath, @INC;
         local @INC = @etc_dirs;
-        require $args{'File'};
+        eval { require $args{'File'} };
+        if ( $@ && $@ !~ /did not return a true value/ ) {
+            die $@;
+        }
     };
     if ($@) {
         return 1 if $is_site && $@ =~ /^Can't locate \Q$args{File}/;

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


More information about the rt-commit mailing list