Foswiki on GitHub is open for business! Next release meeting: Monday September 1, 1300Z

Item9827: Foswiki::Meta interface change breaks plugins

Priority: CurrentState: AppliesTo: Component: WaitingFor:
Urgent Closed Engine Foswiki::Meta  
Foswikirev:2957 changed the interface to Foswiki::Meta::getRevisionInfo() from
getRevisionInfo($fromrev) -> ( $date, $author, $rev, $comment )
... to ...
getRevisionInfo($fromrev) -> \%info 

This breaks plugins (e.g. PublishPlugin) that use Foswiki::Meta::getRevisionInfo().

Foswiki::Func::readTopic returns a Foswiki::Meta object. That object is not documented as opaque. Rather, the readTopic documentation says This class is fully documented in the source code documentation shipped with the release, or can be inspected in the lib/Foswiki/Meta.pm file

Thus, I think it is reasonable for PublishPlugin to use Foswiki::Meta::getRevisionInfo(). So, the interface should not have changed in a non-compatible way.

I propose to restore functionality by changing Foswiki::Meta::getRevisionInfo() as follows:
Index: Meta.pm
===================================================================
--- Meta.pm   (revision 9559)
+++ Meta.pm   (working copy)
@@ -1227,6 +1227,11 @@
    * ={author}= canonical user ID
    * ={version}= the revision number
 
+---++ ObjectMethod getRevisionInfo() -> ( $revDate, $author, $rev, $comment )
+
+Limited backwards compatibility for plugins that assume the 1.0.x interface
+The comment is *always* blank
+
 =cut
 
 sub getRevisionInfo {
@@ -1261,7 +1266,16 @@
         # cache the result
         $this->setRevisionInfo(%$info);
     }
-    return $info;
+
+    if (wantarray)
+    {
+        # Backwards compatibility for 1.0.x plugins
+        return ( $info->{date}, $info->{author}, $info->{version}, '' );
+    }
+    else
+    {
+        return $info;
+    }
 }
 
 # Determines, and caches, the topic revision info of the base version,

-- MichaelTempest - 14 Oct 2010

Oh, bugger. Yes, your change is good.

-- CrawfordCurrie - 14 Oct 2010
 

ItemTemplate edit

Summary Foswiki::Meta interface change breaks plugins
ReportedBy MichaelTempest
Codebase 1.1.0, trunk
SVN Range
AppliesTo Engine
Component Foswiki::Meta
Priority Urgent
CurrentState Closed
WaitingFor
Checkins Foswikirev:9563 Foswikirev:9564
TargetRelease patch
ReleasedIn 1.1.1
Topic revision: r6 - 25 Oct 2010, KennethLavrsen
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons License