diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 5c953e4f0..cecf7039e 100644 --- a/docs/changelog/7.x.x.txt +++ b/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 diff --git a/lib/WebGUI/AssetMetaData.pm b/lib/WebGUI/AssetMetaData.pm index e408c33f4..b776a629e 100644 --- a/lib/WebGUI/AssetMetaData.pm +++ b/lib/WebGUI/AssetMetaData.pm @@ -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 @@ -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. diff --git a/t/Asset/AssetMetaData.t b/t/Asset/AssetMetaData.t index 016eafaca..ed0e9b155 100644 --- a/t/Asset/AssetMetaData.t +++ b/t/Asset/AssetMetaData.t @@ -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}); @@ -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;