From: <Cra...@nt...> - 2005-09-17 07:54:12
|
Author: CrawfordCurrie Date: 2005-09-17 00:51:58 -0700 (Sat, 17 Sep 2005) New Revision: 6403 Modified: twiki/branches/DEVELOP/lib/TWiki/Func.pm twiki/branches/DEVELOP/lib/TWiki/User.pm twiki/branches/DEVELOP/test/unit/FuncTests.pm twiki/branches/DEVELOP/twikiplugins/ContributorsPlugin/lib/TWiki/Plugins/ContributorsPlugin.pm Log: Item381: JaredRhine pointed out an error in the Func API, and provided a patch for corrections to ContributorsPlugin Modified: twiki/branches/DEVELOP/lib/TWiki/Func.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/Func.pm 2005-09-17 07:48:09 UTC (rev 6402) +++ twiki/branches/DEVELOP/lib/TWiki/Func.pm 2005-09-17 07:51:58 UTC (rev 6403) @@ -856,21 +856,30 @@ * =$attachment= -attachment filename Return: =( $date, $user, $rev, $comment )= List with: ( last update date, login name of last user, minor part of top revision number ), e.g. =( 1234561, 'phoeny', "5" )= | $date | in epochSec | -| $user | | -| $rev | | +| $user | Wiki name of the author (*not* login name) | +| $rev | actual rev number | | $comment | WHAT COMMENT? | -NOTE if you are trying to get revision info for a topic, use +NOTE: if you are trying to get revision info for a topic, use $meta->getRevisionInfo instead if you can - it is significantly -more efficient. +more efficient, and returns a user object that contains other user +information. +NOTE: prior versions of TWiki may under some circumstances have returned +the login name of the user rather than the wiki name; the code documentation +was totally unclear, and we have been unable to establish the intent. +However the wikiname is obviously more useful, so that is what is returned. + *Since:* TWiki::Plugins::VERSION 1.000 (29 Jul 2001) =cut sub getRevisionInfo { ASSERT($TWiki::Plugins::SESSION) if DEBUG; - return $TWiki::Plugins::SESSION->{store}->getRevisionInfo( @_ ); + my( $date, $user, $rev, $comment ) = + $TWiki::Plugins::SESSION->{store}->getRevisionInfo( @_ ); + $user = $user->wikiName(); + return ( $date, $user, $rev, $comment ); } =pod Modified: twiki/branches/DEVELOP/lib/TWiki/User.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/User.pm 2005-09-17 07:48:09 UTC (rev 6402) +++ twiki/branches/DEVELOP/lib/TWiki/User.pm 2005-09-17 07:51:58 UTC (rev 6403) @@ -57,7 +57,7 @@ =pod ----++ ClassMethod new( $users, $name, $wikiname ) +---++ ClassMethod new( $session, $loginname, $wikiname ) Construct a new user object for the given login name, wiki name. Modified: twiki/branches/DEVELOP/test/unit/FuncTests.pm =================================================================== --- twiki/branches/DEVELOP/test/unit/FuncTests.pm 2005-09-17 07:48:09 UTC (rev 6402) +++ twiki/branches/DEVELOP/test/unit/FuncTests.pm 2005-09-17 07:51:58 UTC (rev 6403) @@ -208,6 +208,23 @@ $this->assert_str_equals($data, $x); } +sub test_getrevinfo { + my $this = shift; + my $topic = "RevInfo"; + + $twiki = new TWiki( ); + $TWiki::Plugins::SESSION = $twiki; + + my $testuser = new TWiki::User( $twiki, "lunch", "PeterRabbit" ); + $twiki->{user} = $testuser; + TWiki::Func::saveTopicText( $testweb, $topic, 'blah' ); + + my( $date, $user, $rev, $comment ) = + TWiki::Func::getRevisionInfo( $testweb, $topic ); + $this->assert_equals( 1, $rev ); + $this->assert_str_equals( "PeterRabbit", $user ); +} + sub test_moveTopic { my $this = shift; my $twiki = new TWiki(); Modified: twiki/branches/DEVELOP/twikiplugins/ContributorsPlugin/lib/TWiki/Plugins/ContributorsPlugin.pm =================================================================== --- twiki/branches/DEVELOP/twikiplugins/ContributorsPlugin/lib/TWiki/Plugins/ContributorsPlugin.pm 2005-09-17 07:48:09 UTC (rev 6402) +++ twiki/branches/DEVELOP/twikiplugins/ContributorsPlugin/lib/TWiki/Plugins/ContributorsPlugin.pm 2005-09-17 07:51:58 UTC (rev 6403) @@ -127,9 +127,9 @@ my @lines; if( $session ) { @lines = $meta->getRevisionInfo(); - $lines[1] = $lines[1]->wikiName(); + $lines[1] = $lines[1]; } else { - @lines = TWiki::Store::getRevisionInfo($web, $topic, $revision); + @lines = TWiki::Func::getRevisionInfo($web, $topic, $revision); } for ($lineIndex = 0; $lineIndex < $#lines; $lineIndex += 4) { |