Changeset 3892 for trunk/lib/MT.pm

Show
Ignore:
Timestamp:
06/19/09 12:23:48 (5 months ago)
Author:
fumiakiy
Message:

Merging changes to MT.pm.pre to MT.pm from fringale.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/MT.pm

    r3581 r3892  
    545545            $settings = $plugin->{registry}{config_settings} = $settings->() 
    546546              if ref($settings) eq 'CODE'; 
    547             $class->config->define($settings); 
     547            $class->config->define($settings) if $settings; 
    548548        } 
    549549    } 
     
    828828    my ($param) = @_; 
    829829 
    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    } 
    835839 
    836840    # translate the config file's location to an absolute path, so we 
    837841    # can use that directory as a basis for calculating other relative 
    838842    # 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}); 
    840844 
    841845    # store the mt_dir (home) as an absolute path; fallback to the config 
     
    850854    # checking the PWD environment variable, the dirname of $0, 
    851855    # 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    } 
    862868 
    863869    my $cfg = $mt->config; 
    864870    $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 ); 
    867872 
    868873    my @mt_paths = $cfg->paths; 
     
    881886            } 
    882887            else { 
     888                next if ref($path); # unexpected referene, ignore 
    883889                if ( !File::Spec->file_name_is_absolute($path) ) { 
    884890                    $path = File::Spec->catfile( $config_dir, $path ); 
     
    10541060    my ($param) = @_; 
    10551061    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 
    10561072    $cfg->read_config_db(); 
    1057  
    1058     # Tell any instantiated drivers to reconfigure themselves as necessary 
    1059     MT::ObjectDriverFactory->configure; 
    10601073 
    10611074    1; 
     
    11971210    $mt->init_lang_defaults(@_) or return; 
    11981211    require MT::Plugin; 
    1199     $mt->init_addons(@_)       or return; 
     1212    $mt->init_addons(@_)        or return; 
    12001213    $mt->init_config_from_db( \%param ) or return; 
    12011214    $mt->init_plugins(@_)       or return; 
     
    14051418                            next; 
    14061419                        } 
     1420                        next if exists $Plugins{$plugin_dir}; 
    14071421                        my $id = lc $plugin_dir; 
    14081422                        $id =~ s/\.\w+$//; 
     
    14181432                        local $plugin_sig = $plugin_dir; 
    14191433                        MT->add_plugin($p); 
    1420                         $p->init_callbacks() 
    1421                             if $pclass eq 'MT::Plugin'; 
     1434                        $p->init_callbacks(); 
    14221435                        next; 
    14231436                    } 
     
    22962309    my $timeout = exists $opt->{timeout} ? $opt->{timeout} : $cfg->HTTPTimeout || $cfg->PingTimeout; 
    22972310    my $proxy = exists $opt->{proxy} ? $opt->{proxy} : $cfg->HTTPProxy || $cfg->PingProxy; 
     2311    my $sec_proxy = exists $opt->{sec_proxy} ? $opt->{sec_proxy} : $cfg->HTTPSProxy; 
    22982312    my $no_proxy = exists $opt->{no_proxy} ? $opt->{no_proxy} : $cfg->HTTPNoProxy || $cfg->PingNoProxy; 
    22992313    my $agent = $opt->{agent} || 'MovableType/' . $MT::VERSION; 
     
    23152329        my @domains = split( /,\s*/, $no_proxy ) if $no_proxy; 
    23162330        $ua->no_proxy(@domains) if @domains; 
     2331    } 
     2332    if ( defined $sec_proxy ) { 
     2333        $ua->proxy ( https => $sec_proxy ); 
    23172334    } 
    23182335    return $ua; 
     
    30473064} 
    30483065 
    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 } 
     3066sub DESTROY { } 
    30543067 
    305530681;