Changeset 3892
- Timestamp:
- 06/19/09 12:23:48 (5 months ago)
- Files:
-
- 1 modified
-
trunk/lib/MT.pm (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/MT.pm
r3581 r3892 545 545 $settings = $plugin->{registry}{config_settings} = $settings->() 546 546 if ref($settings) eq 'CODE'; 547 $class->config->define($settings) ;547 $class->config->define($settings) if $settings; 548 548 } 549 549 } … … 828 828 my ($param) = @_; 829 829 830 my $cfg_file = $mt->find_config($param); 831 return $mt->error( 832 "Missing configuration file. Maybe you forgot to move mt-config.cgi-original to mt-config.cgi?" 833 ) unless $cfg_file; 834 $cfg_file = File::Spec->rel2abs($cfg_file); 830 unless ($mt->{cfg_file}) { 831 my $cfg_file = $mt->find_config($param); 832 833 return $mt->error( 834 "Missing configuration file. Maybe you forgot to move mt-config.cgi-original to mt-config.cgi?" 835 ) unless $cfg_file; 836 $cfg_file = File::Spec->rel2abs($cfg_file); 837 $mt->{cfg_file} = $cfg_file; 838 } 835 839 836 840 # translate the config file's location to an absolute path, so we 837 841 # can use that directory as a basis for calculating other relative 838 842 # paths found in the config file. 839 my $config_dir = $mt->{config_dir} = dirname($ cfg_file);843 my $config_dir = $mt->{config_dir} = dirname($mt->{cfg_file}); 840 844 841 845 # store the mt_dir (home) as an absolute path; fallback to the config … … 850 854 # checking the PWD environment variable, the dirname of $0, 851 855 # the directory of SCRIPT_FILENAME and lastly, falls back to mt_dir 852 $mt->{app_dir} = $ENV{PWD} || ""; 853 $mt->{app_dir} = dirname($0) 854 if !$mt->{app_dir} 855 || !File::Spec->file_name_is_absolute( $mt->{app_dir} ); 856 $mt->{app_dir} = dirname( $ENV{SCRIPT_FILENAME} ) 857 if $ENV{SCRIPT_FILENAME} 858 && ( !$mt->{app_dir} 859 || ( !File::Spec->file_name_is_absolute( $mt->{app_dir} ) ) ); 860 $mt->{app_dir} ||= $mt->{mt_dir}; 861 $mt->{app_dir} = File::Spec->rel2abs( $mt->{app_dir} ); 856 unless ($mt->{app_dir}) { 857 $mt->{app_dir} = $ENV{PWD} || ""; 858 $mt->{app_dir} = dirname($0) 859 if !$mt->{app_dir} 860 || !File::Spec->file_name_is_absolute( $mt->{app_dir} ); 861 $mt->{app_dir} = dirname( $ENV{SCRIPT_FILENAME} ) 862 if $ENV{SCRIPT_FILENAME} 863 && ( !$mt->{app_dir} 864 || ( !File::Spec->file_name_is_absolute( $mt->{app_dir} ) ) ); 865 $mt->{app_dir} ||= $mt->{mt_dir}; 866 $mt->{app_dir} = File::Spec->rel2abs( $mt->{app_dir} ); 867 } 862 868 863 869 my $cfg = $mt->config; 864 870 $cfg->define( $mt->registry('config_settings') ); 865 $cfg->read_config($cfg_file) or return $mt->error( $cfg->errstr ); 866 $mt->{cfg_file} = $cfg_file; 871 $cfg->read_config($mt->{cfg_file}) or return $mt->error( $cfg->errstr ); 867 872 868 873 my @mt_paths = $cfg->paths; … … 881 886 } 882 887 else { 888 next if ref($path); # unexpected referene, ignore 883 889 if ( !File::Spec->file_name_is_absolute($path) ) { 884 890 $path = File::Spec->catfile( $config_dir, $path ); … … 1054 1060 my ($param) = @_; 1055 1061 my $cfg = $mt->config; 1062 1063 # Tell any instantiated drivers to reconfigure themselves as necessary 1064 require MT::ObjectDriverFactory; 1065 if (MT->config('ObjectDriver')) { 1066 my $driver = MT::ObjectDriverFactory->instance; 1067 $driver->configure if $driver; 1068 } else { 1069 MT::ObjectDriverFactory->configure(); 1070 } 1071 1056 1072 $cfg->read_config_db(); 1057 1058 # Tell any instantiated drivers to reconfigure themselves as necessary1059 MT::ObjectDriverFactory->configure;1060 1073 1061 1074 1; … … 1197 1210 $mt->init_lang_defaults(@_) or return; 1198 1211 require MT::Plugin; 1199 $mt->init_addons(@_) or return;1212 $mt->init_addons(@_) or return; 1200 1213 $mt->init_config_from_db( \%param ) or return; 1201 1214 $mt->init_plugins(@_) or return; … … 1405 1418 next; 1406 1419 } 1420 next if exists $Plugins{$plugin_dir}; 1407 1421 my $id = lc $plugin_dir; 1408 1422 $id =~ s/\.\w+$//; … … 1418 1432 local $plugin_sig = $plugin_dir; 1419 1433 MT->add_plugin($p); 1420 $p->init_callbacks() 1421 if $pclass eq 'MT::Plugin'; 1434 $p->init_callbacks(); 1422 1435 next; 1423 1436 } … … 2296 2309 my $timeout = exists $opt->{timeout} ? $opt->{timeout} : $cfg->HTTPTimeout || $cfg->PingTimeout; 2297 2310 my $proxy = exists $opt->{proxy} ? $opt->{proxy} : $cfg->HTTPProxy || $cfg->PingProxy; 2311 my $sec_proxy = exists $opt->{sec_proxy} ? $opt->{sec_proxy} : $cfg->HTTPSProxy; 2298 2312 my $no_proxy = exists $opt->{no_proxy} ? $opt->{no_proxy} : $cfg->HTTPNoProxy || $cfg->PingNoProxy; 2299 2313 my $agent = $opt->{agent} || 'MovableType/' . $MT::VERSION; … … 2315 2329 my @domains = split( /,\s*/, $no_proxy ) if $no_proxy; 2316 2330 $ua->no_proxy(@domains) if @domains; 2331 } 2332 if ( defined $sec_proxy ) { 2333 $ua->proxy ( https => $sec_proxy ); 2317 2334 } 2318 2335 return $ua; … … 3047 3064 } 3048 3065 3049 sub DESTROY { 3050 # save_config here so not to miss any dirty config change to persist 3051 # particulary for those which does not construct MT::App. 3052 $_[0]->config->save_config(); 3053 } 3066 sub DESTROY { } 3054 3067 3055 3068 1;
