Changeset 13836


Ignore:
Timestamp:
01/27/12 05:14:49 (4 weeks ago)
Author:
PaulHarvey
Message:

Item11431: add ASSERTs for SINGLE_SINGLETONS

Conflicts:

lib/Foswiki.pm

Location:
branches/Release01x01/core/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/Release01x01/core/lib/Foswiki.pm

    r13483 r13836  
    8080our $OC      = "<!--\0"; 
    8181our $CC      = "\0-->"; 
     82 
     83# This variable is set if Foswiki is running in unit test mode. 
     84# It is provided so that modules can detect unit test mode to avoid 
     85# corrupting data spaces. 
     86our $inUnitTestMode = 0; 
     87 
     88sub SINGLE_SINGLETONS       { 0 } 
     89sub SINGLE_SINGLETONS_TRACE { 0 } 
    8290 
    8391# Returns the full path of the directory containing Foswiki.pm 
     
    16731681        CGI::charset( $Foswiki::cfg{Site}{CharSet} ); 
    16741682    } 
     1683    if (SINGLE_SINGLETONS_TRACE) { 
     1684        require Data::Dumper; 
     1685        print STDERR "new $this: " 
     1686          . Data::Dumper->Dump( [ [caller], [ caller(1) ] ] ); 
     1687    } 
    16751688 
    16761689    $this->{request}  = $query; 
     
    16811694    # This is required in case we get an exception during 
    16821695    # initialisation, so that we have a session to handle it with. 
     1696    ASSERT( !$Foswiki::Plugins::SESSION ) if SINGLE_SINGLETONS; 
    16831697    $Foswiki::Plugins::SESSION = $this; 
     1698    ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; 
    16841699 
    16851700    # Tell Foswiki::Response which charset we are using if not default 
     
    21312146 
    21322147    undef $this->{DebugVerificationCode};    # from Foswiki::UI::Register 
     2148    if (SINGLE_SINGLETONS_TRACE) { 
     2149        require Data::Dumper; 
     2150        print STDERR "finish $this: " 
     2151          . Data::Dumper->Dump( [ [caller], [ caller(1) ] ] ); 
     2152    } 
     2153    if (SINGLE_SINGLETONS) { 
     2154        ASSERT( defined $Foswiki::Plugins::SESSION ); 
     2155        ASSERT( $Foswiki::Plugins::SESSION == $this ); 
     2156        ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ); 
     2157    } 
     2158    undef $Foswiki::Plugins::SESSION; 
    21332159 
    21342160    if (DEBUG) { 
     
    23962422 
    23972423    # Make sure func works, for registered tag handlers 
     2424    if (SINGLE_SINGLETONS) { 
     2425        ASSERT( defined $Foswiki::Plugins::SESSION ); 
     2426        ASSERT( $Foswiki::Plugins::SESSION == $this ); 
     2427    } 
    23982428    local $Foswiki::Plugins::SESSION = $this; 
     2429    ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; 
    23992430 
    24002431    my $text = $topicObject->text(); 
     
    27332764 
    27342765    # Make sure func works, for registered tag handlers 
    2735     $Foswiki::Plugins::SESSION = $this; 
     2766    if (SINGLE_SINGLETONS) { 
     2767        ASSERT( defined $Foswiki::Plugins::SESSION ); 
     2768        ASSERT( $Foswiki::Plugins::SESSION == $this ); 
     2769    } 
     2770    local $Foswiki::Plugins::SESSION = $this; 
     2771    ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; 
    27362772 
    27372773    # NOTE TO DEBUGGERS 
  • branches/Release01x01/core/lib/Foswiki/Func.pm

    r13638 r13836  
    576576    my ( $tag, $function, $syntax ) = @_; 
    577577    ASSERT($Foswiki::Plugins::SESSION) if DEBUG; 
     578    ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; 
    578579 
    579580    # $pluginContext is undefined if a contrib registers a tag handler. 
     
    589590        sub { 
    590591            my ( $session, $params, $topicObject ) = @_; 
    591             my $record = $Foswiki::Plugins::SESSION; 
    592             $Foswiki::Plugins::SESSION = $_[0]; 
     592            local $Foswiki::Plugins::SESSION = $session; 
    593593 
    594594            # $pluginContext is defined for all plugins 
     
    607607 
    608608            # Compatibility; expand $topicObject to the topic and web 
    609             my $result = 
    610               &$function( $session, $params, $topicObject->topic, 
     609            return &$function( $session, $params, $topicObject->topic, 
    611610                $topicObject->web, $topicObject ); 
    612             $Foswiki::Plugins::SESSION = $record; 
    613             return $result; 
    614611        }, 
    615612        $syntax 
     
    704701            my $record = $Foswiki::Plugins::SESSION; 
    705702            $Foswiki::Plugins::SESSION = $_[0]; 
     703            ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; 
    706704            my $result = &$function(@_); 
    707705            $Foswiki::Plugins::SESSION = $record; 
  • branches/Release01x01/core/lib/Foswiki/Plugin.pm

    r11862 r13836  
    164164    # Set the session for this call stack 
    165165    local $Foswiki::Plugins::SESSION = $this->{session}; 
     166    ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; 
    166167 
    167168    my $sub = $p . "::initPlugin"; 
  • branches/Release01x01/core/lib/Foswiki/Plugins.pm

    r12169 r13836  
    225225    # Set the session for this call stack 
    226226    local $Foswiki::Plugins::SESSION = $this->{session}; 
     227    ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; 
    227228 
    228229    foreach my $plugin ( @{ $this->{plugins} } ) { 
     
    247248    # Set the session for this call stack 
    248249    local $Foswiki::Plugins::SESSION = $this->{session}; 
     250    ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; 
    249251 
    250252    foreach my $plugin ( @{ $this->{plugins} } ) { 
     
    326328        # Set the value of $SESSION for this call stack 
    327329        local $SESSION = $this->{session}; 
     330        ASSERT( $Foswiki::Plugins::SESSION->isa('Foswiki') ) if DEBUG; 
    328331 
    329332        # apply handler on the remaining list of args 
Note: See TracChangeset for help on using the changeset viewer.