[Rt-commit] rt branch, 4.4/siteconfig.d, created. rt-4.2.3-204-g19c0a09
? sunnavy
sunnavy at bestpractical.com
Thu Jul 10 20:40:28 EDT 2014
The branch, 4.4/siteconfig.d has been created
at 19c0a09dcf7862c69b85720df5a6ca58fbb8e485 (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 19c0a09dcf7862c69b85720df5a6ca58fbb8e485
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Jun 27 00:16:39 2014 +0800
support config files in RT_SiteConfig.d
besides, it's not necessary to append "1;" any more, which makes writing
config files more easily.
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..d00c243 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 separate configs in F<RT_SiteConfig.pm> into different files(with
+C<.pm> suffix) in F<RT_SiteConfig.d/> now, and they will have higher priority
+than original F<RT_SiteConfig.pm>.
+
=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..751a06d 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -88,6 +88,14 @@ 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.
+
+If you have a lot of things to config, you can separate them into different
+files(with C<.pm> suffix) in F<RT_SiteConfig.d/> directory, and they will
+override settings in F<RT_SiteConfig.pm>.
+
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 +1023,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 +1050,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 : '';
@@ -1075,7 +1093,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