Item9532: topicObject passed to macros might be non-loaded

pencil
Priority: Urgent
Current State: Closed
Released In: 1.1.0
Target Release: minor
Applies To: Engine
Component:
Branches:
Reported By: MichaelDaum
Waiting For:
Last Change By: CrawfordCurrie
As a result things like %META{"attachments"}% don't display the list of available attachments.

Not sure why it isn't loaded. All I have found out so far is that

--- lib/Foswiki/Macros/META.pm  (revision 8712)
+++ lib/Foswiki/Macros/META.pm  (working copy)
@@ -12,6 +12,9 @@
 
     my $option = $params->{_DEFAULT} || '';
 
+    my $loadedRev = $topicObject->getLoadedRev();
+    $topicObject->load() unless defined $loadedRev;
+

cures the symptoms.

So...the recent Meta.pm related checkins at Item9487 and Item9482 did not fix all of the remaining problems ... the bottle of whiskey goes the other way.

-- MichaelDaum - 23 Aug 2010

Try to view Support.BestPracticeTip18 on trunk. I get the following backtrace:

Assertion (Attempt to reload 1 over version 2) failed!
 at /usr/home/trunk.foswiki.org/core/lib/Assert.pm line 80
   Assert::ASSERT(0, 'Attempt to reload 1 over version 2') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Meta.pm line 843
   Foswiki::Meta::loadVersion('Foswiki::Meta=HASH(0x1629488)', 1) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Meta.pm line 298
   Foswiki::Meta::load('Foswiki::Meta=HASH(0x1629488)', 1) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Render.pm line 1617
   Foswiki::Render::renderRevisionInfo('Foswiki::Render=HASH(0x2511e98)', 'Foswiki::Meta=HASH(0x1629488)', 1, '$wikiusername') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Macros/REVINFO.pm line 30
   Foswiki::REVINFO('Foswiki=HASH(0xddc6d8)', 'Foswiki::Attrs=HASH(0x1629478)', 'Foswiki::Meta=HASH(0x14fe668)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki.pm line 3016
   Foswiki::_expandMacroOnTopicRendering('Foswiki=HASH(0xddc6d8)', 'REVINFO', '"$wikiusername" topic="BestPracticeTip18" rev="1.1"', 'Foswiki::Meta=HASH(0x14fe668)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki.pm line 2906
   Foswiki::_processMacros('Foswiki=HASH(0xddc6d8)', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN...', 'CODE(0xd4bde8)', 'Foswiki::Meta=HASH(0x14fe668)', 16) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki.pm line 2703
   Foswiki::innerExpandMacros('Foswiki=HASH(0xddc6d8)', 'SCALAR(0xd4c658)', 'Foswiki::Meta=HASH(0x14fe668)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki.pm line 3193
   Foswiki::expandMacros('Foswiki=HASH(0xddc6d8)', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN...', 'Foswiki::Meta=HASH(0x14fe668)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Meta.pm line 2956
   Foswiki::Meta::expandMacros('Foswiki::Meta=HASH(0x14fe668)', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN...') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI/View.pm line 399
   Foswiki::UI::View::_prepare('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN...', 'Foswiki::Meta=HASH(0x14fe668)', 0) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI/View.pm line 359
   Foswiki::UI::View::view('Foswiki=HASH(0xddc6d8)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 310
   Foswiki::UI::__ANON__() called at /usr/local/lib/perl5/site_perl/5.8.8/Error.pm line 415
   eval {...} called at /usr/local/lib/perl5/site_perl/5.8.8/Error.pm line 407
   Error::subs::try('CODE(0xd8bc48)', 'HASH(0xddc3c8)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 429
   Foswiki::UI::_execute('Foswiki::Request=HASH(0xdbf568)', 'CODE(0xdbf128)', 'view', 1) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 277
   Foswiki::UI::handleRequest('Foswiki::Request=HASH(0xdbf568)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Engine/CGI.pm line 30
   Foswiki::Engine::CGI::run('Foswiki::Engine::CGI=HASH(0x901668)') called at /home/trunk.foswiki.org/core/bin/view line 24
 at /usr/home/trunk.foswiki.org/core/lib/Assert.pm line 80
   Assert::ASSERT(0, 'Attempt to reload 1 over version 2') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Meta.pm line 843
   Foswiki::Meta::loadVersion('Foswiki::Meta=HASH(0x1629488)', 1) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Meta.pm line 298
   Foswiki::Meta::load('Foswiki::Meta=HASH(0x1629488)', 1) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Render.pm line 1617
   Foswiki::Render::renderRevisionInfo('Foswiki::Render=HASH(0x2511e98)', 'Foswiki::Meta=HASH(0x1629488)', 1, '$wikiusername') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Macros/REVINFO.pm line 30
   Foswiki::REVINFO('Foswiki=HASH(0xddc6d8)', 'Foswiki::Attrs=HASH(0x1629478)', 'Foswiki::Meta=HASH(0x14fe668)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki.pm line 3016
   Foswiki::_expandMacroOnTopicRendering('Foswiki=HASH(0xddc6d8)', 'REVINFO', '"$wikiusername" topic="BestPracticeTip18" rev="1.1"', 'Foswiki::Meta=HASH(0x14fe668)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki.pm line 2906
   Foswiki::_processMacros('Foswiki=HASH(0xddc6d8)', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN...', 'CODE(0xd4bde8)', 'Foswiki::Meta=HASH(0x14fe668)', 16) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki.pm line 2703
   Foswiki::innerExpandMacros('Foswiki=HASH(0xddc6d8)', 'SCALAR(0xd4c658)', 'Foswiki::Meta=HASH(0x14fe668)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki.pm line 3193
   Foswiki::expandMacros('Foswiki=HASH(0xddc6d8)', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN...', 'Foswiki::Meta=HASH(0x14fe668)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Meta.pm line 2956
   Foswiki::Meta::expandMacros('Foswiki::Meta=HASH(0x14fe668)', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN...') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI/View.pm line 399
   Foswiki::UI::View::_prepare('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN...', 'Foswiki::Meta=HASH(0x14fe668)', 0) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI/View.pm line 359
   Foswiki::UI::View::view('Foswiki=HASH(0xddc6d8)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 310
   Foswiki::UI::__ANON__() called at /usr/local/lib/perl5/site_perl/5.8.8/Error.pm line 415
   eval {...} called at /usr/local/lib/perl5/site_perl/5.8.8/Error.pm line 407
   Error::subs::try('CODE(0xd8bc48)', 'HASH(0xddc3c8)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 429
   Foswiki::UI::_execute('Foswiki::Request=HASH(0xdbf568)', 'CODE(0xdbf128)', 'view', 1) called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 277
   Foswiki::UI::handleRequest('Foswiki::Request=HASH(0xdbf568)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Engine/CGI.pm line 30
   Foswiki::Engine::CGI::run('Foswiki::Engine::CGI=HASH(0x901668)') called at /home/trunk.foswiki.org/core/bin/view line 24.

-- PaulHarvey

It isn't loaded because of the case where a page can be rendered without loading it; always force-loading would be a pointless expense.

You might think this unlikely but consider this:
  • A request that creates a new topic, passed in the path info
  • A request to just execute a plugin macro that does something that doesn't require a loaded topic

So your fix is fine. However the stacktrace behind the twisty is related to REVINFO and is AFAICT unrelated to META.

BTW you are welcome to whiskey, as long as I can have whisky smile (the 'e' is only used in the vastly inferior Irish and American products).

-- CrawfordCurrie - 24 Aug 2010

You are the expert on whisk(e)y smile

Okay so always force-loading isn't what it is expected. I was under the impression that the current topicObject within the parse loop is always in state loaded being handed over to the macro handlers.

There might be other macros that need above fix. Attachments is only the most obvious one.

-- MichaelDaum - 24 Aug 2010

 

ItemTemplate edit

Summary topicObject passed to macros might be non-loaded
ReportedBy MichaelDaum
Codebase trunk
SVN Range
AppliesTo Engine
Component
Priority Urgent
CurrentState Closed
WaitingFor
Checkins distro:f43704a005bd
TargetRelease minor
ReleasedIn 1.1.0
Topic revision: r7 - 06 Sep 2010, CrawfordCurrie
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