Changeset 1769

Show
Ignore:
Timestamp:
04/04/08 06:08:04 (4 months ago)
Author:
fumiakiy
Message:

Stopped saving something in the database while database driver is being initialized. Let us see if this fixes the occasional "Time to Upgrade!" bug. BugId:58199

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-33/lib/MT.pm.pre

    r1716 r1769  
    26842684} 
    26852685 
     2686sub DESTROY { 
     2687    # save_config here so not to miss any dirty config change to persist 
     2688    # particulary for those which does not construct MT::App. 
     2689    $_[0]->config->save_config(); 
     2690} 
     2691 
    268626921; 
    26872693 
  • branches/release-33/lib/MT/App.pm

    r1719 r1769  
    23872387    } 
    23882388 
     2389    # save_config here so not to miss any dirty config change to persist 
     2390    $app->config->save_config(); 
     2391 
    23892392    $app->request->finish; 
    23902393    delete $app->{request}; 
     
    30663069    MT::Request->finish(); 
    30673070    undef $MT::Object::DRIVER; 
     3071    undef $MT::Object::DBI_DRIVER; 
    30683072    undef $MT::ConfigMgr::cfg; 
    30693073} 
  • branches/release-33/lib/MT/ConfigMgr.pm

    r1174 r1769  
    1717 
    1818sub new { 
    19     my $mgr = bless { __var => { }, __dbvar => { }, __paths => [] }, $_[0]; 
     19    my $mgr = bless { __var => { }, __dbvar => { }, __paths => [], __dirty => 0 }, $_[0]; 
    2020    $mgr->init; 
    2121    $mgr; 
     
    162162        $mgr->{$set}{$var} = $val; 
    163163    } 
     164    $mgr->set_dirty() if defined($_[2]) && $_[2]; 
    164165} 
    165166 
     
    186187} 
    187188 
     189sub set_dirty { 
     190    my $mgr = shift; 
     191    $mgr = $mgr->instance unless ref($mgr); 
     192    $mgr->{__dirty} = 1; 
     193} 
     194 
     195sub clear_dirty { 
     196    my $mgr = shift; 
     197    $mgr = $mgr->instance unless ref($mgr); 
     198    $mgr->{__dirty} = 0; 
     199} 
     200 
     201sub is_dirty { 
     202    my $mgr = shift; 
     203    $mgr = $mgr->instance unless ref($mgr); 
     204    $mgr->{__dirty}; 
     205} 
     206 
    188207sub save_config { 
    189208    my $class = shift; 
    190209    my $mgr = $class->instance; 
     210    return 0 unless $mgr->is_dirty(); 
    191211    my $data = ''; 
    192212    my $settings = $mgr->{__dbvar}; 
     
    220240    $config->data($data); 
    221241    $config->save or die $config->errstr; 
     242    $mgr->clear_dirty; 
     243    1; 
    222244} 
    223245 
  • branches/release-33/lib/MT/ObjectDriver/Driver/DBD/Pg.pm

    r1174 r1769  
    107107        local $@; 
    108108        if (!$dbh->do("SET NAMES '" . $c . "'")) { 
    109             # 'set names' command isn't working for this verison of mysql
     109            # 'set names' command isn't working for this verison of PostgreSQL
    110110            # assign SQLSetNames to 0 to prevent further errors. 
    111111            $cfg->SQLSetNames(0, 1); 
    112             $cfg->save_config; 
    113112            return 0; 
    114113        } else { 
     
    117116                # 'SET NAMES' command, so it's safe to SET NAMES in the future. 
    118117                $cfg->SQLSetNames(1, 1); 
    119                 $cfg->save_config; 
    120118            } 
    121119        } 
  • branches/release-33/lib/MT/ObjectDriver/Driver/DBD/mysql.pm

    r1174 r1769  
    7777                # 'SET NAMES' command, so it's safe to SET NAMES in the future. 
    7878                $cfg->SQLSetNames(1, 1); 
    79                 $cfg->save_config; 
    8079            } 
    8180        } else { 
     
    8382            # assign SQLSetNames to 0 to prevent further errors. 
    8483            $cfg->SQLSetNames(0, 1); 
    85             $cfg->save_config; 
    8684            return 0; 
    8785        }