diff --git a/core/lib/Foswiki/Meta.pm b/core/lib/Foswiki/Meta.pm index fa9165c..535e4b1 100644 --- a/core/lib/Foswiki/Meta.pm +++ b/core/lib/Foswiki/Meta.pm @@ -1796,6 +1796,16 @@ sub save { $signal = shift; }; + # Refresh preferences values + if ( $this->{_web} && $this->{_topic} && !defined $signal ) { + + # Refresh is needed only if preferences were already loaded. + # If not, they'll get loaded lazily (and up-to-date) when needed. + if ( $this->{_preferences} ) { + $this->{_preferences}->refresh(); + } + } + # Semantics inherited from TWiki. See # TWiki:Codev.BugBeforeSaveHandlerBroken if ( $plugins->haveHandlerFor('afterSaveHandler') ) { diff --git a/core/lib/Foswiki/Prefs/BaseBackend.pm b/core/lib/Foswiki/Prefs/BaseBackend.pm index fef003b..fbc774f 100644 --- a/core/lib/Foswiki/Prefs/BaseBackend.pm +++ b/core/lib/Foswiki/Prefs/BaseBackend.pm @@ -104,6 +104,18 @@ sub insert { =begin TML +---++ ObjectMethod refresh() + +Parse the topic again to get the most up-to-date preferences. + +=cut + +sub refresh { + ASSERT('Pure virtual method - child classes must redefine'); +} + +=begin TML + ---++ ObjectMethod cleanupInsertValue($value_ref) Utility method that cleans $$vaue_ref for later use in insert(). diff --git a/core/lib/Foswiki/Prefs/Parser.pm b/core/lib/Foswiki/Prefs/Parser.pm index fc826e9..8f1fe05 100644 --- a/core/lib/Foswiki/Prefs/Parser.pm +++ b/core/lib/Foswiki/Prefs/Parser.pm @@ -30,12 +30,13 @@ Parse settings from the topic and add them to the preferences in $prefs =cut sub parse { - my ( $topicObject, $prefs ) = @_; + my ($prefs) = @_; # Process text first my $key = ''; my $value = ''; my $type; + my $topicObject = $prefs->topicObject; my $text = $topicObject->text(); $text = '' unless defined $text; diff --git a/core/lib/Foswiki/Prefs/TopicRAM.pm b/core/lib/Foswiki/Prefs/TopicRAM.pm index bb49e2e..b526b69 100644 --- a/core/lib/Foswiki/Prefs/TopicRAM.pm +++ b/core/lib/Foswiki/Prefs/TopicRAM.pm @@ -29,7 +29,7 @@ sub new { $this->{local} = {}; if ( $topicObject->existsInStore() ) { - Foswiki::Prefs::Parser::parse( $topicObject, $this ); + Foswiki::Prefs::Parser::parse($this); } $this->{topicObject} = $topicObject; @@ -76,6 +76,15 @@ sub getLocal { return $this->{local}{$key}; } +sub refresh { + my $this = shift; + $this->{values} = {}; + $this->{local} = {}; + if ( $this->{topicObject}->existsInStore() ) { + Foswiki::Prefs::Parser::parse($this); + } +} + sub insert { my ( $this, $type, $key, $value ) = @_;