Permalink
Browse files

Item14401: Don't crash if PageCache can't load

And add checkers to try to avoid the issue.
  • Loading branch information...
gac410 committed May 22, 2017
1 parent a521a8e commit 36956afc18f17304bb0033dc2d64950df393d0c0
View
@@ -2122,8 +2122,13 @@ sub new {
if ( $Foswiki::cfg{Cache}{Enabled} && $Foswiki::cfg{Cache}{Implementation} )
{
eval "require $Foswiki::cfg{Cache}{Implementation}";
ASSERT( !$@, $@ ) if DEBUG;
$this->{cache} = $Foswiki::cfg{Cache}{Implementation}->new();
if ($@) { # The require failed - Be graceful in failure
ASSERT( !$@, $@ ) if DEBUG;
$Foswiki::cfg{Cache}{Enabled} = 0;
}
else {
$this->{cache} = $Foswiki::cfg{Cache}{Implementation}->new();
}
}
my $prefs = new Foswiki::Prefs($this);
View
@@ -1611,7 +1611,7 @@ $Foswiki::cfg{FormTypes} = [
# This setting will switch on/off caching.
$Foswiki::cfg{Cache}{Enabled} = $FALSE;
# **SELECTCLASS Foswiki::PageCache::DBI::* DISPLAY_IF="{Cache}{Enabled}" CHECK="iff:'{Cache}{Enabled}'" LABEL="Cache Implementation"**
# **SELECTCLASS Foswiki::PageCache::DBI::* DISPLAY_IF="{Cache}{Enabled}" CHECK="iff:'{Cache}{Enabled}' also:'{Cache}{Enabled}'" LABEL="Cache Implementation"**
# Select the cache implementation. The default page cache implementation
# is based on DBI (http://dbi.perl.org) which requires a working DBI driver to
# connect to a database. This database will hold all cached data as well as the
@@ -0,0 +1,41 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::Cache::Enabled;
use strict;
use warnings;
use Foswiki::Configure::Checker ();
our @ISA = ('Foswiki::Configure::Checker');
sub check {
my ( $this, $value ) = @_;
if ( $Foswiki::cfg{Cache}{Enabled} && $Foswiki::cfg{Cache}{Implementation} )
{
eval "require $Foswiki::cfg{Cache}{Implementation}";
if ($@) { # The require failed - Be graceful in failure
$this->ERROR("Cache cannot be enabled - Failed to load!");
$this->NOTE($@);
}
}
}
1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2017 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read LICENSE in the root of this distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As per the GPL, removal of this notice is prohibited.
@@ -368,6 +368,7 @@ lib/Foswiki/Configure/Checkers/AccessibleCFG.pm 0444
lib/Foswiki/Configure/Checkers/AccessControlACL/EnableDeprecatedEmptyDeny.pm 0444
lib/Foswiki/Configure/Checkers/AuthRealm.pm 0444
lib/Foswiki/Configure/Checkers/AuthScripts.pm 0444
lib/Foswiki/Configure/Checkers/Cache/Enabled.pm 0444
lib/Foswiki/Configure/Checkers/Cache/DependencyFilter.pm 0444
lib/Foswiki/Configure/Checkers/Cache/Implementation.pm 0444
lib/Foswiki/Configure/Checkers/Certificate/ClientChecker.pm 0444

0 comments on commit 36956af

Please sign in to comment.