Permalink
Browse files

Item14315: Don't load latest rev in attachments table

The attachments table uses QUERY to get the attachments count.  For this
to be correct, it needs to specify the rev of the topic being used.

Also the QUERY macro, when asked to expand {Configuration}{Keys} does
not need to load a topic rev.

Last, when QUERY does have to load the latest revision of a topic, load
a  new topic object, don't try to reload the passed object.  That's what
causes the ASSERT - loading a new rev into an existing object.
  • Loading branch information...
gac410 committed Jan 31, 2017
1 parent b0abf0b commit 54c394fad3a6e5a8c42b09ad190863c6e972778a
Showing with 22 additions and 16 deletions.
  1. +2 −2 PatternSkin/templates/attachtables.pattern.tmpl
  2. +20 −14 core/lib/Foswiki/Macros/QUERY.pm
@@ -3,7 +3,7 @@
%TMPL:DEF{"commonattachtableattributes"}%valign="middle" dataalign="left,left,left,right,left,left,left,left" datavalign="top" headeralign="left" headercolor="#0066cc" databg="#ffffff" headerbg="#ffffff" headerbgsorted="#eeeeee" databgsorted="#f5f5f5" %TMPL:END%
-%TMPL:DEF{"topicattachmentwisty"}%%TWISTY{id="topicattachmentslist" mode="div" remember="on" showimgleft="%ICONURLPATH{toggleopen}%" hideimgleft="%ICONURLPATH{toggleclose}%" link="%MAKETEXT{"Attachments [_1]" args="<span class='foswikiSmall foswikiGrayText'>%QUERY{"length(attachments[NOT lc(attr)=~'h'])"}%</span>"}%" linkclass="patternTwistyButton"}%%TMPL:END%
+%TMPL:DEF{"topicattachmentwisty"}%%TWISTY{id="topicattachmentslist" mode="div" remember="on" showimgleft="%ICONURLPATH{toggleopen}%" hideimgleft="%ICONURLPATH{toggleclose}%" link="%MAKETEXT{"Attachments [_1]" args="<span class='foswikiSmall foswikiGrayText'>%QUERY{"length(attachments[NOT lc(attr)=~'h'])" rev="%URLPARAM{"rev"}%"}%</span>"}%" linkclass="patternTwistyButton"}%%TMPL:END%
%{ Header definition for topic attachments and top table in attach screen }%
%TMPL:DEF{ATTACH:files:header(basic)}%<div class="foswikiAttachments">
@@ -21,4 +21,4 @@
%TMPL:END%
%{ Footer for topic attachment table }%
-%TMPL:DEF{ATTACH:files:footer}%%ENDTWISTY%</div>%TMPL:P{ATTACH:files:footer:script}%%TMPL:END%
+%TMPL:DEF{ATTACH:files:footer}%%ENDTWISTY%</div>%TMPL:P{ATTACH:files:footer:script}%%TMPL:END%
@@ -25,25 +25,31 @@ sub QUERY {
}
$style = Foswiki::Sandbox::untaintUnchecked($style);
- my $rev = $params->{rev};
-
- # FORMFIELD does its own caching.
- # Either the home-made cache there should go into Meta so that both
- # FORMFIELD and QUERY benefit, or the store should be made a lot smarter.
+ # Config key queries don't need / care about topic versions.
+ if ( $expr !~ m/^\{.*\}$/ ) {
+
+ my $rev = $params->{rev};
+
+ # FORMFIELD does its own caching.
+ # Either the home-made cache there should go into Meta so that both
+ # FORMFIELD and QUERY benefit, or the store should be made a lot smarter.
+
+ if ( defined $rev && length($rev) ) {
+ my $crev = $topicObject->getLoadedRev();
+ if ( defined $crev && $crev != $rev ) {
+ $topicObject =
+ Foswiki::Meta->load( $topicObject->session, $topicObject->web,
+ $topicObject->topic, $rev );
+ }
+ }
+ elsif ( !$topicObject->latestIsLoaded() ) {
- if ( defined $rev ) {
- my $crev = $topicObject->getLoadedRev();
- if ( defined $crev && $crev != $rev ) {
+ # load latest rev
$topicObject =
Foswiki::Meta->load( $topicObject->session, $topicObject->web,
- $topicObject->topic, $rev );
+ $topicObject->topic );
}
}
- elsif ( !$topicObject->latestIsLoaded() ) {
-
- # load latest rev
- $topicObject = $topicObject->load();
- }
# Recursion block.
$this->{evaluatingEval} ||= {};

0 comments on commit 54c394f

Please sign in to comment.