Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item13986: Fix bug discovered in prefs and meta
This was masked by a bug in the unit test.  Thanks to VadimBelman for
the fix.
  • Loading branch information
gac410 committed Nov 1, 2016
1 parent 62d92f1 commit 9e6a267
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
7 changes: 4 additions & 3 deletions UnitTestContrib/test/unit/PluginHandlerTests.pm
Expand Up @@ -188,7 +188,7 @@ sub beforeSaveHandler {
$tester->assert_str_equals($tester->{test_web}, $_[2], "THREE $_[2]");
$tester->assert($_[3]->isa('Foswiki::Meta'), "FOUR $_[3]");
$tester->assert_str_equals('Wibble', $_[3]->get('WIBBLE')->{wibble});
Foswiki::Func::pushTopicContext( $this->{test_web}, 'Tropic' );
Foswiki::Func::pushTopicContext( $tester->{test_web}, 'Tropic' );
$tester->assert_str_equals( "BEFORE",
$_[3]->getPreference("BLAH"));
#Foswiki::Func::getPreferencesValue("BLAH") );
Expand Down Expand Up @@ -833,8 +833,9 @@ HERE
my $hashRef = eval
"\$Foswiki::Plugins::$this->{plugin_name}::called->{renderWikiWordHandlerLinks}";
use Data::Dumper;
print STDERR "------ $html\n";
print STDERR "------ " . Dumper($hashRef) . "\n";

#print STDERR "------ $html\n";
#print STDERR "------ " . Dumper($hashRef) . "\n";

#this is what we have - and it shows that you need to call expandMacros before calling renderText
$this->assert_deep_equals(
Expand Down
1 change: 1 addition & 0 deletions core/lib/Foswiki/Meta.pm
Expand Up @@ -1188,6 +1188,7 @@ sub text {
_assertIsTopic($this) if DEBUG;
if ( defined($val) ) {
$this->{_text} = $val;
$this->{_session}->{prefs}->invalidatePath($this);
}
else {

Expand Down
20 changes: 20 additions & 0 deletions core/lib/Foswiki/Prefs.pm
@@ -1,6 +1,7 @@
# See bottom of file for license and copyright information
use strict;
use warnings;
use Error;

BEGIN {
if ( $Foswiki::cfg{UseLocale} ) {
Expand Down Expand Up @@ -252,6 +253,25 @@ sub loadPreferences {
return $obj;
}

sub invalidatePath {
my $this = shift;
my $path;
if ( ref( $_[0] ) ) {
ASSERT( $_[0]->isa('Foswiki::Meta') ) if DEBUG;
$path = $_[0]->getPath;
}
else {
$path = $_[0];
}

if ( $this->{paths}->{$path} ) {

#print STDERR "INVALIDATED: $this->{paths}->{$path}\n";
delete $this->{paths}->{$path};
}

}

=begin TML
---++ ObjectMethod pushTopicContext( $web, $topic )
Expand Down

0 comments on commit 9e6a267

Please sign in to comment.