Skip to content

Commit

Permalink
Item11945:
Browse files Browse the repository at this point in the history
   * don't cache invalid form objects
   * don't cache it under the wrong key
   * don't look up form objs using the wrong key

also:
   * report compilation errors eval'ing formfield classes



git-svn-id: http://svn.foswiki.org/trunk@14981 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Jun 14, 2012
1 parent 04c23fa commit 2b941c9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions core/lib/Foswiki/Form.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ in the database is protected against view.
sub new {
my ( $class, $session, $web, $form, $def ) = @_;

my $this = $session->{forms}->{"$web.$form"};
my ( $vweb, $vtopic ) = $session->normalizeWebTopicName( $web, $form );
my $this = $session->{forms}->{"$vweb.$vtopic"};

unless ($this) {

# A form name has to be a valid topic name after normalisation
my ( $vweb, $vtopic ) = $session->normalizeWebTopicName( $web, $form );
$vweb = Foswiki::Sandbox::untaint( $vweb,
\&Foswiki::Sandbox::validateWebName );
$vtopic = Foswiki::Sandbox::untaint( $vtopic,
Expand All @@ -105,18 +106,16 @@ sub new {
}

$this = $class->SUPER::new( $session, $vweb, $vtopic );
$session->{forms}->{"$web.$form"} = $this;

unless ( $def || $this->haveAccess('VIEW') ) {
throw Foswiki::AccessControlException( 'VIEW', $session->{user},
$web, $form, $Foswiki::Meta::reason );
$vweb, $vtopic, $Foswiki::Meta::reason );
}

if ( ref($this) ne 'Foswiki::Form' ) {

#recast if we have to - allowing the cache to work its magic
$this = bless( $this, 'Foswiki::Form' );
$session->{forms}->{"$web.$form"} = $this;
}

unless ($def) {
Expand All @@ -130,6 +129,9 @@ sub new {
# Foswiki::Meta object
$this->{fields} = $this->_extractPseudoFieldDefs($def);
}

# cache the object when properly build
$session->{forms}->{"$vweb.$vtopic"} = $this;
}

return $this;
Expand Down Expand Up @@ -314,6 +316,8 @@ sub createField {
);
eval 'require ' . $class;
if ($@) {
$this->session->logger->log( 'error',
"error compiling class $class: $@" );

# Type not available; use base type
require Foswiki::Form::FieldDefinition;
Expand Down

0 comments on commit 2b941c9

Please sign in to comment.