Item13986: Any changes to a topic text made after pushing the topic to the context stack are ignored even changes are related to topic-level preferences.
Priority: Urgent
Current State: Closed
Released In: 2.1.3
Target Release: patch
Suspected bug is masked by a mistype in
PluginHandlerTests.
diff --git a/UnitTestContrib/test/unit/PluginHandlerTests.pm b/UnitTestContrib/test/unit/PluginHandlerTests.pm
index bcfe9e4..deafa31 100644
--- a/UnitTestContrib/test/unit/PluginHandlerTests.pm
+++ b/UnitTestContrib/test/unit/PluginHandlerTests.pm
@@ -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") );
Because
$this
is used instead of correct
$tester
undef
is passed over to
pushTopicContext
and preferences are read from
$cfg{UsersWebName}
instead of correct the test web. Eventually this path gets stored in
$session->{prefs}->{paths}
with empty
values
key. So when it comes later to read the
BLAH
preference it is read from the topic as should.
By replacing
$this
with
$tester
we get completely different picture: correct path to the topic Tropic in test web is stored in the
paths
with a copy of old topic version and
BLAH
set to
BEFORE
.
The essence of the bug is following: any changes to a topic text made after pushing the topic to the context stack are ignored even changes are related to topic-level preferences.
Suggested fix would be deleting topic path from preferences
paths
key whenever
Foswiki::Meta::text()
is called to change the topic text. I'm gonna test this fix in
Item13897 branch.
--
VadimBelman - 23 Feb 2016
The fix in the 13897 branch is:
has text => (
is => 'rw',
lazy => 1,
predicate => 1,
clearer => 1,
trigger => sub {
my $this = shift;
$this->app->prefs->invalidatePath($this)
if $this->app && $this->app->has_prefs;
--
GeorgeClark - 01 Nov 2016