Changeset 13839


Ignore:
Timestamp:
01/27/12 06:04:41 (4 weeks ago)
Author:
PaulHarvey
Message:

Item11431: TWikiCompat, Don't Foswiki->new/finish

I don't understand why TWiki.pm needs to $query = undef here. Doing
that based on there being an undef $Foswiki::Plugins::SESSION makes
it impossible to create a new TWiki session object without violating
the one-instance-of-the-damn-singleton-at-a-time policy.

Location:
branches/Release01x01/TWikiCompatibilityPlugin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/Release01x01/TWikiCompatibilityPlugin/lib/TWiki.pm

    r7644 r13839  
    1111    if ( !$Foswiki::Plugins::SESSION && UNIVERSAL::isa( $query, 'CGI' ) ) { 
    1212 
    13         # Compatibility: User gave a CGI object 
    14         # This probably means we're inside a script 
    15         $query = undef; 
     13        ## Compatibility: User gave a CGI object 
     14        ## This probably means we're inside a script 
     15        ## $query = undef; 
     16        # The above was added in Item689, Foswikirev:1847. It doesn't make any 
     17        # sense to me. PH disabled under Item11431 ('no singleton left behind') 
    1618    } 
    1719    my $fatwilly = new Foswiki( $loginName, $query, $initialContext ); 
  • branches/Release01x01/TWikiCompatibilityPlugin/test/unit/TWikiCompatibilityPlugin/TWikiFuncTests.pm

    r13427 r13839  
    4545    my $this = shift; 
    4646 
    47     $this->{session}->finish(); 
    48     $this->{session} = Foswiki->new( $Foswiki::cfg{AdminUserLogin} ); 
     47    $this->createNewFoswikiSession( $Foswiki::cfg{AdminUserLogin} ); 
    4948 
    5049    TWiki::Func::createWeb( $this->{test_web} . "/Blah" ); 
     
    6261    my $this = shift; 
    6362 
    64     $this->{session}->finish(); 
    65     $this->{session} = Foswiki->new( $Foswiki::cfg{AdminUserLogin} ); 
     63    $this->createNewFoswikiSession( $Foswiki::cfg{AdminUserLogin} ); 
    6664 
    6765    $this->assert( Foswiki::Func::webExists('TWiki') ); 
     
    9997    $this->assert_matches( qr!/$ss/$this->{test_web}/WebHome!, $result ); 
    10098 
     99    $this->finishFoswikiSession(); 
    101100    $TWiki::Plugins::SESSION = 
    102101      TWiki->new( undef, 
    103102        Unit::Request->new( { topic => "Sausages.AndMash" } ) ); 
     103    $this->{session} = $TWiki::Plugins::SESSION; 
    104104 
    105105    $result = TWiki::Func::getViewUrl( "Sausages", "AndMash" ); 
     
    108108    $result = TWiki::Func::getViewUrl( "", "AndMash" ); 
    109109    $this->assert_matches( qr!/$ss/Sausages/AndMash!, $result ); 
    110     $TWiki::Plugins::SESSION->finish(); 
     110    $this->createNewFoswikiSession(); 
    111111 
    112112    return; 
     
    126126    my $q = Unit::Request->new( {} ); 
    127127    $q->path_info('/Sausages/AndMash'); 
     128    $this->finishFoswikiSession(); 
    128129    $TWiki::Plugins::SESSION = TWiki->new( undef, $q ); 
     130    $this->{session} = $TWiki::Plugins::SESSION; 
    129131 
    130132    $result = TWiki::Func::getScriptUrl( "Sausages", "AndMash", 'wibble' ); 
     
    133135    $result = TWiki::Func::getScriptUrl( "", "AndMash", 'wibble' ); 
    134136    $this->assert_matches( qr!/$ss/$this->{users_web}/AndMash!, $result ); 
    135     $TWiki::Plugins::SESSION->finish(); 
     137    $this->createNewFoswikiSession(); 
    136138 
    137139    return; 
     
    546548END 
    547549    ); 
    548     eval { $this->{session}->finish() }; 
     550    $this->finishFoswikiSession(); 
    549551    $this->{session} = TWiki->new(); 
    550552    $TWiki::Plugins::SESSION = $this->{session}; 
     
    610612    ); 
    611613    $this->assert( !$access ); 
     614    $this->createNewFoswikiSession(); 
    612615 
    613616    return; 
     
    624627END 
    625628    ); 
    626     eval { $this->{session}->finish() }; 
     629    $this->finishFoswikiSession(); 
    627630    $this->{session} = TWiki->new(); 
    628631    $TWiki::Plugins::SESSION = $this->{session}; 
     
    888891    my $this = shift; 
    889892    $this->assert( TWiki::Func::isGuest(), $this->{session}->{user} ); 
    890     $this->{session}->finish(); 
     893    $this->finishFoswikiSession(); 
    891894    $this->{session} = TWiki->new( $TWiki::cfg{AdminUserLogin} ); 
     895    $TWiki::Plugins::SESSION = $this->{session}; 
    892896    $this->assert( !TWiki::Func::isGuest(), $this->{session}->{user} ); 
     897    $this->createNewFoswikiSession(); 
    893898 
    894899    return; 
     
    909914   * Set FINALPREFERENCES = PSIBG 
    910915HERE 
    911     $this->{session}->finish(); 
     916    $this->finishFoswikiSession(); 
    912917    $this->{session} = TWiki->new( $TWiki::cfg{GuestUserLogin}, $q ); 
     918    $TWiki::Plugins::SESSION = $this->{session}; 
    913919    $this->assert_str_equals( "naff", 
    914920        TWiki::Func::getPreferencesValue("PSIBG") ); 
     
    921927   * Set PSIBG = naff 
    922928HERE 
    923     $this->{session}->finish(); 
     929    $this->finishFoswikiSession(); 
    924930    $this->{session} = TWiki->new( $TWiki::cfg{GuestUserLogin}, $q ); 
     931    $TWiki::Plugins::SESSION = $this->{session}; 
    925932    $this->assert_str_equals( "naff", 
    926933        TWiki::Func::getPreferencesValue("PSIBG") ); 
     
    928935    $this->assert_str_equals( "KJHD", 
    929936        TWiki::Func::getPreferencesValue("PSIBG") ); 
     937    $this->createNewFoswikiSession(); 
    930938 
    931939    return; 
Note: See TracChangeset for help on using the changeset viewer.