Skip to content

Commit

Permalink
- fixed #12365: editing a metadata category may cause a fatal error
Browse files Browse the repository at this point in the history
  • Loading branch information
arjancwidlak committed Jun 5, 2012
1 parent 8370cb1 commit 7ab4726
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changelog/7.x.x.txt
@@ -1,4 +1,5 @@
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 #12010 related link duplication where links have group view restrictions
- fixed #12297: keywords.form missing from Post template help
Expand Down
3 changes: 2 additions & 1 deletion lib/WebGUI/AssetMetaData.pm
Expand Up @@ -388,6 +388,7 @@ sub www_editMetaDataField {
my %usedNames;
for my $class (WebGUI::Pluggable::findAndLoad('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};
next unless $name; # abstract classes (e.g. wobject) don't have names

Expand Down Expand Up @@ -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.
Expand Down
17 changes: 16 additions & 1 deletion t/Asset/AssetMetaData.t
Expand Up @@ -24,7 +24,7 @@ use WebGUI::VersionTag;

use Test::More; # increment this value for each test you create
use Test::Deep;
plan tests => 16;
plan tests => 17;

my $session = WebGUI::Test->session;
$session->user({userId => 3});
Expand Down Expand Up @@ -305,6 +305,21 @@ subtest 'asset metadata versioning' => sub {
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 {
my ($fidStruct) = @_;
my $nameStruct;
Expand Down

0 comments on commit 7ab4726

Please sign in to comment.