Skip to content

Commit

Permalink
Item13753: ref operator fails on certain conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Sep 25, 2015
1 parent aa3510b commit a4aa39b
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 22 deletions.
45 changes: 29 additions & 16 deletions data/System/DBCacheContrib.txt
@@ -1,5 +1,6 @@
%META:TOPICINFO{author="ProjectContributor" comment="autosave" date="1398768235" format="1.1" version="1"}%
---+!! %TOPIC%
%SHORTDESCRIPTION%

Reusable code that caches Foswiki topics, and provides fast
searches of the content.
Expand Down Expand Up @@ -114,22 +115,24 @@ cache is automatically updated.
Clients use the DBCache by defining a subclass of the
=Foswiki::Contrib::DBCacheContrib= class. Implementors are stongly recommended to read the POD documentation in the code:

<!--
* Set SHORTDESCRIPTION = %$SHORTDESCRIPTION%
-->

---++ Installation Instructions
%$INSTALL_INSTRUCTIONS%

---++ Contrib Info
| Author: | Foswiki:Main/CrawfordCurrie http://c-dot.co.uk, Foswiki:Main/MichaelDaum https://www.michaeldaumconsulting.com |
| Copyright &copy;: | This code is based on an original development of Motorola Inc. and is protected by the following copyrights: <br>Copyright @copy 2002-2003 Motorola Inc. All Rights Reserved. %BR%\
Portions copyright &copy; 2004 Crawford Currie http://www.c-dot.co.uk. %BR%\
Portions copyright &copy; 2013-2014 Michael Daum http://michaeldaumconsulting.com |
| License: | GPL |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | |
---++ Copyright &copy;

This code is based on an original development of Motorola Inc. and is protected by the following copyrights:

* Copyright &copy; 2002-2003 Motorola Inc. All Rights Reserved.
* Portions copyright &copy; 2004 Crawford Currie http://www.c-dot.co.uk.
* Portions copyright &copy; 2013-2015 Michael Daum http://michaeldaumconsulting.com

---++ Dependencies
%$DEPENDENCIES%

---++ Change History

%TABLE{columnwidths="7em" tablewidth="100%"}%
| 25 Sep 2015 | Foswikitask:Item13753: ref operator fails under certain conditions |
| 12 Jan 2015 | Foswikitask:Item13148: added support for CPAN:Sereal |
| 29 Apr 2014 | Foswikitask:Item12877: web parameter might be tainted |
| 18 Mar 2014 | Foswikitask:Item12789: fix dereferencing unblessed cache map |
Expand Down Expand Up @@ -188,7 +191,17 @@ Clients use the DBCache by defining a subclass of the
| 5005 | Poddified documentation |
| 5003 | Initial version |
| 8 Jul 2004 | Initial version, split out from <nop>FormQueryPlugin |
| Dependencies: | %$DEPENDENCIES% |
| Home: | http://foswiki.org/Extensions/%TOPIC% |
| Support: | http://foswiki.org/Support/%TOPIC% |

<!--
* Set SHORTDESCRIPTION = %$SHORTDESCRIPTION%
-->

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Foswiki:Main/CrawfordCurrie http://c-dot.co.uk, Foswiki:Main/MichaelDaum https://www.michaeldaumconsulting.com"}%
%META:FIELD{name="Copyright" title="Copyright" value="Copyright &copy; 2002-2003 Motorola Inc. All Rights Reserved. Portions copyright &copy; 2004 Crawford Currie http://www.c-dot.co.uk. Portions copyright &copy; 2013-2015 Michael Daum http://michaeldaumconsulting.com"}%
%META:FIELD{name="Home" title="Home" value="http://foswiki.org/Extensions/%TOPIC%"}%
%META:FIELD{name="License" title="License" value="GPL"}%
%META:FIELD{name="Release" title="Release" value="%$RELEASE%"}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/DBCacheContrib"}%
%META:FIELD{name="Support" title="Support" value="http://foswiki.org/Support/%TOPIC%"}%
%META:FIELD{name="Version" title="Version" value="%$VERSION%"}%
24 changes: 24 additions & 0 deletions lib/CPAN/lib/Sereal.pm
@@ -0,0 +1,24 @@
package Sereal;
use 5.008;
use strict;
use warnings;
our $VERSION = '3.00';
our $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
use Sereal::Encoder qw(encode_sereal sereal_encode_with_object);
use Sereal::Decoder
qw(decode_sereal looks_like_sereal sereal_decode_with_object);

use Exporter 'import';
our @EXPORT_OK = qw(
encode_sereal decode_sereal
looks_like_sereal
sereal_encode_with_object
sereal_decode_with_object
);
our %EXPORT_TAGS = ( all => \@EXPORT_OK );

# export by default if run from command line
our @EXPORT = ( ( caller() )[1] eq '-e' ? @EXPORT_OK : () );

1;
4 changes: 2 additions & 2 deletions lib/Foswiki/Contrib/DBCacheContrib.pm
Expand Up @@ -41,8 +41,8 @@ FormQueryPlugin for an example of this.
=cut

our $VERSION = '4.00';
our $RELEASE = '4.00';
our $VERSION = '4.01';
our $RELEASE = '25 Sep 2015';
our $SHORTDESCRIPTION =
'Reusable code that treats forms as if they were table rows in a database';

Expand Down
2 changes: 2 additions & 0 deletions lib/Foswiki/Contrib/DBCacheContrib/Config.spec
Expand Up @@ -34,3 +34,5 @@ $Foswiki::cfg{DBCacheContrib}{AlwaysUpdateCache} = $FALSE;
# WARNING: setting this to any value higher than zero can result in the
# cache becoming out of sync with the .txt files.
$Foswiki::cfg{DBCacheContrib}{LoadFileLimit} = 0;

1;
10 changes: 10 additions & 0 deletions lib/Foswiki/Contrib/DBCacheContrib/MANIFEST
@@ -1,4 +1,5 @@
data/System/DBCacheContrib.txt 0644
lib/CPAN/lib/Sereal.pm 0644
lib/Foswiki/Contrib/DBCacheContrib/Archivable.pm 0644
lib/Foswiki/Contrib/DBCacheContrib/Archivist/BDB/Array.pm 0644
lib/Foswiki/Contrib/DBCacheContrib/Archivist/BDB/Collection.pm 0644
Expand All @@ -11,10 +12,19 @@ lib/Foswiki/Contrib/DBCacheContrib/Archivist/Serializable.pm 0644
lib/Foswiki/Contrib/DBCacheContrib/Archivist/Storable.pm 0644
lib/Foswiki/Contrib/DBCacheContrib/Array.pm 0644
lib/Foswiki/Contrib/DBCacheContrib/Config.spec 0644
lib/Foswiki/Contrib/DBCacheContrib/DEPENDENCIES 0644
lib/Foswiki/Contrib/DBCacheContrib/Map.pm 0644
lib/Foswiki/Contrib/DBCacheContrib/MemArchivist.pm 0644
lib/Foswiki/Contrib/DBCacheContrib/MemArray.pm 0644
lib/Foswiki/Contrib/DBCacheContrib/MemMap.pm 0644
lib/Foswiki/Contrib/DBCacheContrib.pm 0644
lib/Foswiki/Contrib/DBCacheContrib/Search.pm 0644
lib/Foswiki/Contrib/DBCacheContrib/SegmentMap.pm 0644
test/unit/DBCacheContrib/ArrayTest.pm 0644
test/unit/DBCacheContrib/DBCacheContribSuite.pm 0644
test/unit/DBCacheContrib/DBCacheContribTestCase.pm 0644
test/unit/DBCacheContrib/DBCacheTest.pm 0644
test/unit/DBCacheContrib/MapTest.pm 0644
test/unit/DBCacheContrib/SearchTest.pm 0644
test/unit/DBCacheContrib/testDB.dat 0644
TIDY 0644
18 changes: 14 additions & 4 deletions lib/Foswiki/Contrib/DBCacheContrib/Search.pm
Expand Up @@ -31,6 +31,7 @@ contract with the rest of the world.
package Foswiki::Contrib::DBCacheContrib::Search;

use strict;
use warnings;
use Assert;

# Operator precedences
Expand Down Expand Up @@ -403,21 +404,30 @@ sub OP_ref {
$ref = $form->FETCH($ref);
return undef unless $ref; # unknown field

my ( $refWeb, $refTopic ) =
Foswiki::Func::normalizeWebTopicName( $webDB ? $webDB->{_web} : '',
$ref );
if ( !$webDB || $refWeb ne $webDB->{_web} ) {
$webDB = Foswiki::Plugins::DBCachePlugin::Core::getDB($refWeb);
}

# get topic object
unless ( defined $webDB ) {
die "WARNING: no cache found in context";
return 0;
print STDERR
"WARNING: web $refWeb not found processing REF operator\n";
return undef;
}

$map = $webDB->fastget($ref);
return undef unless $map; # unknown ref
$map = $webDB->fastget($refTopic);
return undef unless $map;
}

# the tail is a property of the referenced topic
my $val = $map->get( $map->get("form") )->get($r);
unless ($val) {
$val = $map->get($r);
}

return $val;
}

Expand Down

0 comments on commit a4aa39b

Please sign in to comment.