Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item10678: add META:CREATEINFO to QUERY and SEARCH, so you can search…
… on META:CREATEINFO.date

git-svn-id: http://svn.foswiki.org/trunk@11618 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed May 4, 2011
1 parent 6cdc8dd commit 8fbf490
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
33 changes: 33 additions & 0 deletions UnitTestContrib/test/unit/QueryTests.pm
Expand Up @@ -312,6 +312,39 @@ sub verify_meta_dot {
$this->check( "fields.number", eval => 99 );
$this->check( "fields.string", eval => 'String' );
$this->check( "notafield.string", eval => undef );

#longhand
$this->check( "META:TOPICINFO.date", eval => $info->{date} );
$this->check( "META:TOPICINFO.format", eval => 1.1 );
$this->check( "META:TOPICINFO.version", eval => $info->{version} );
$this->check( "META:TOPICINFO.author", eval => $info->{author} );

#longhand to a topic that as more than one rev
my $anotherTopic = Foswiki::Meta->new( $this->{session}, $this->{test_web}, 'AnotherTopic' );
my $anotherTopicInfo = $anotherTopic->getRevisionInfo();
$this->check( "'AnotherTopic'/META:TOPICINFO.date", eval => $anotherTopicInfo->{date} );
$this->check( "'AnotherTopic'/META:TOPICINFO.format", eval => 1.1 );
$this->check( "'AnotherTopic'/META:TOPICINFO.version", eval => $anotherTopicInfo->{version} );
$this->check( "'AnotherTopic'/META:TOPICINFO.author", eval => $anotherTopicInfo->{author} );

$anotherTopic->getRev1Info('createdate');
my $anotherTopicInfoRev1 = $anotherTopic->{_getRev1Info}->{rev1info};
$this->check( "'AnotherTopic'/META:CREATEINFO.date", eval => $anotherTopicInfoRev1->{date} );
#interestingly, format is not compulsory
# $this->check( "'AnotherTopic'/META:CREATEINFO.format", eval => 1.1 );
$this->check( "'AnotherTopic'/META:CREATEINFO.version", eval => $anotherTopicInfoRev1->{version} );
$this->check( "'AnotherTopic'/META:CREATEINFO.author", eval => $anotherTopicInfoRev1->{author} );

$this->assert($anotherTopicInfoRev1->{version} < $anotherTopicInfo->{version}, $anotherTopicInfoRev1->{version}.' < '.$anotherTopicInfo->{version});


#longhand to a topic that doesn't exist
$this->check( "'DoesNotExist'/META:TOPICINFO.date", syntaxOnly=>1, eval => undef );
$this->check( "'DoesNotExist'/META:TOPICINFO.format", syntaxOnly=>1, eval => undef );
$this->check( "'DoesNotExist'/META:TOPICINFO.version", syntaxOnly=>1, eval => undef );
$this->check( "'DoesNotExist'/META:TOPICINFO.author", syntaxOnly=>1, eval => undef );


}

sub verify_array_integer_index {
Expand Down
4 changes: 4 additions & 0 deletions core/data/System/QuerySearch.txt
Expand Up @@ -38,6 +38,10 @@ All meta-data in a topic is referenced according to a simple plan.
* =date=
* =format=
* =version= - topic version (integer)
* =META:CREATEINFO= - version info for the first version of the topic
* =author=
* =date=
* =version= - topic version (integer)
* =META:TOPICMOVED=
* =by=
* =date=
Expand Down
25 changes: 25 additions & 0 deletions core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm
Expand Up @@ -92,6 +92,11 @@ sub getField {
# Ensure the revision info is populated from the store
$data->getRevisionInfo();
}
if ( $field eq 'CREATEINFO' ) {

# Ensure the revision info is populated from the store
return $this->getRev1Info($data);
}

if ( $Foswiki::Query::Node::isArrayType{$field} ) {

Expand Down Expand Up @@ -200,6 +205,26 @@ sub getRefTopic {
return $meta;
}

=begin TML
---++ StaticMethod getRev1Info($meta) -> %info
Return revision info for the first revision in %info with at least:
* ={date}= in epochSec
* ={author}= canonical user ID
* ={version}= the revision number
=cut

# Default implements gets a new Foswiki::Meta
sub getRev1Info {
my $this = shift;
my $meta = shift;

my $wikiname = $meta->getRev1Info('createwikiname');
return $meta->{_getRev1Info}->{rev1info};
}

1;
__END__
Expand Down

0 comments on commit 8fbf490

Please sign in to comment.