You are here: Foswiki>Tasks Web>Item8901 (19 Apr 2010, MichaelDaum)Edit Attach

Item8901: META macro might show old revision information

pencil
Priority: Urgent
Current State: Closed
Released In:
Target Release: minor
Applies To: Engine
Component:
Branches:
Reported By: MichaelDaum
Waiting For:
Last Change By: MichaelDaum
For some reason there exist two distinct code paths where a call to %Meta{"form"}% might not show the form information of the latest but some abitrary earlier version of a topic.

The following patch cures it:
--- lib/Foswiki/Macros/META.pm  (revision 7180)
+++ lib/Foswiki/Macros/META.pm  (working copy)
@@ -6,8 +6,8 @@
 # Poor-man's content access.
 sub META {
     my ( $this, $params, $topicObject ) = @_;
-
-    $topicObject->reload() unless $topicObject->getLoadedRev();
+
+    $topicObject->reload() if $topicObject->getLoadedRev() < $topicObject->getMaxRevNo();

The former code could be paraphrased as "load the topicObject unless it wasn't loaded already". This also means that it won't reload the topicObject with the latest revision if it somehow already has been loaded with an older revision ... which it actually should.

The new code is paraphrased as "reload the topicObject if the loaded revision is earlier than the latest one" ... which also covers the "not loaded yet" state as getLoadedRev() will return 0 in that case.

-- MichaelDaum - 13 Apr 2010

Reopening. This is still not fixed as Meta::reload() does not reload the latest revision unconditionally. When the $rev param to Meta::reload() is undefined, it reuses the {_loadedRev} param as stored in the topicObject ... dunno why that.

A Meta::reload(0) forces the store to realy reload the latest revision.

-- MichaelDaum - 13 Apr 2010

Right... and as documented recently, that is the expected behaviour. The logic is that you need some way to (1) load a specific revision (2) load the latest revision and (3) reload a possibly tainted revision from the store. To do that you need a three state parameter, and I used (1) defined param within the range of valid revisions (2) defined param outside the range of valid revisions (3) undefined parameter. So if you want to reload the latest revision, pass 0.

-- CrawfordCurrie - 14 Apr 2010

Still not bullet proved. It also needs to reload when the loaded revision is higher than the max rev in the repository ... for whatever reason.

-- MichaelDaum - 15 Apr 2010

That's what "If 0 or > max available rev, will reload the latest rev" in the doc means.

-- CrawfordCurrie - 18 Apr 2010

Well, basically, the last checkin covers an error case where the loaded rev is higher than the max rev. So it's okay now.

-- MichaelDaum - 19 Apr 2010
 
Topic revision: r10 - 19 Apr 2010, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy