- fixed #12365: editing a metadata category may cause a fatal error

This commit is contained in:
Arjan Widlak 2012-06-05 12:34:50 +02:00
parent 8370cb15c8
commit 7ab4726600
3 changed files with 19 additions and 2 deletions

View file

@ -1,4 +1,5 @@
7.10.25 7.10.25
- fixed #12365: editing a metadata may cause a fatal error (Arjan Widlak / United Knowledge)
- fixed #12346: toVersion in upgrade_7.9.34-7.10.22.pl was "0.0.0" - fixed #12346: toVersion in upgrade_7.9.34-7.10.22.pl was "0.0.0"
- fixed #12010 related link duplication where links have group view restrictions - fixed #12010 related link duplication where links have group view restrictions
- fixed #12297: keywords.form missing from Post template help - fixed #12297: keywords.form missing from Post template help

View file

@ -388,6 +388,7 @@ sub www_editMetaDataField {
my %usedNames; my %usedNames;
for my $class (WebGUI::Pluggable::findAndLoad('WebGUI::Asset')) { for my $class (WebGUI::Pluggable::findAndLoad('WebGUI::Asset')) {
next unless $class->isa('WebGUI::Asset'); next unless $class->isa('WebGUI::Asset');
next unless isIn( $class, keys %{ $self->session->config->get("assets") } );
my $name = $class->definition($self->session)->[0]->{assetName}; my $name = $class->definition($self->session)->[0]->{assetName};
next unless $name; # abstract classes (e.g. wobject) don't have names next unless $name; # abstract classes (e.g. wobject) don't have names
@ -480,7 +481,7 @@ sub www_editMetaDataFieldSave {
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 www_manageMetaData ( ) =head2 www_manageMetaData ( )n
Returns an AdminConsole to deal with MetaDataFields. If isInGroup(4) is False, renders an insufficient privilege page. Returns an AdminConsole to deal with MetaDataFields. If isInGroup(4) is False, renders an insufficient privilege page.

View file

@ -24,7 +24,7 @@ use WebGUI::VersionTag;
use Test::More; # increment this value for each test you create use Test::More; # increment this value for each test you create
use Test::Deep; use Test::Deep;
plan tests => 16; plan tests => 17;
my $session = WebGUI::Test->session; my $session = WebGUI::Test->session;
$session->user({userId => 3}); $session->user({userId => 3});
@ -305,6 +305,21 @@ subtest 'asset metadata versioning' => sub {
is $count_all->($dup), 1, 'one value for dup'; is $count_all->($dup), 1, 'one value for dup';
}; };
# Check that www_editMetaDataField doesn't return assets that are not configured
# for this site and that sub definition is not executed if the asset is not
# configured in the config, which may cause a fatal error.
# Temporarily remove asset Article from config
$session->config->deleteFromHash( 'assets', 'WebGUI::Asset::Wobject::Article' );
unlike(
my $got = $root->www_editMetaDataField(),
qr/WebGUI::Asset::Wobject::Article/,
'article was (temporarily) not in config and should not appear in form'
);
# Restore config:
$session->config->addToHash( 'assets', 'WebGUI::Asset::Wobject::Article' );
sub buildNameIndex { sub buildNameIndex {
my ($fidStruct) = @_; my ($fidStruct) = @_;
my $nameStruct; my $nameStruct;