You are here: Foswiki>Tasks Web>Item13986 (18 Feb 2017, GeorgeClark)Edit Attach

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.

pencil
Priority: Urgent
Current State: Closed
Released In: 2.1.3
Target Release: patch
Applies To: Engine
Component: FoswikiPrefs
Branches: Release02x01 master
Reported By: VadimBelman
Waiting For:
Last Change By: GeorgeClark
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
 

ItemTemplate edit

Summary 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.
ReportedBy VadimBelman
Codebase 2.1.2, 2.1.1, 2.1.0, 2.1.0 beta1, 2.0.3, 2.0.2, 2.0.1, 2.0.0
SVN Range
AppliesTo Engine
Component FoswikiPrefs
Priority Urgent
CurrentState Closed
WaitingFor
Checkins distro:9e6a2679b440 distro:e42889fb1a87
TargetRelease patch
ReleasedIn 2.1.3
CheckinsOnBranches Release02x01 master
trunkCheckins
masterCheckins distro:9e6a2679b440 distro:e42889fb1a87
ItemBranchCheckins
Release02x01Checkins distro:9e6a2679b440
Release02x00Checkins
Release01x01Checkins
Topic revision: r7 - 18 Feb 2017, GeorgeClark - This page was cached on 23 Feb 2017 - 06:14.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License