Skip to content

Commit 7ab4726

Browse files
committedJun 5, 2012
- fixed #12365: editing a metadata category may cause a fatal error

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed
 

‎docs/changelog/7.x.x.txt

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

‎lib/WebGUI/AssetMetaData.pm

+2-1
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ sub www_editMetaDataField {
388388
my %usedNames;
389389
for my $class (WebGUI::Pluggable::findAndLoad('WebGUI::Asset')) {
390390
next unless $class->isa('WebGUI::Asset');
391+
next unless isIn( $class, keys %{ $self->session->config->get("assets") } );
391392
my $name = $class->definition($self->session)->[0]->{assetName};
392393
next unless $name; # abstract classes (e.g. wobject) don't have names
393394

@@ -480,7 +481,7 @@ sub www_editMetaDataFieldSave {
480481

481482
#-------------------------------------------------------------------
482483

483-
=head2 www_manageMetaData ( )
484+
=head2 www_manageMetaData ( )n
484485
485486
Returns an AdminConsole to deal with MetaDataFields. If isInGroup(4) is False, renders an insufficient privilege page.
486487

‎t/Asset/AssetMetaData.t

+16-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use WebGUI::VersionTag;
2424

2525
use Test::More; # increment this value for each test you create
2626
use Test::Deep;
27-
plan tests => 16;
27+
plan tests => 17;
2828

2929
my $session = WebGUI::Test->session;
3030
$session->user({userId => 3});
@@ -305,6 +305,21 @@ subtest 'asset metadata versioning' => sub {
305305
is $count_all->($dup), 1, 'one value for dup';
306306
};
307307

308+
# Check that www_editMetaDataField doesn't return assets that are not configured
309+
# for this site and that sub definition is not executed if the asset is not
310+
# configured in the config, which may cause a fatal error.
311+
312+
# Temporarily remove asset Article from config
313+
$session->config->deleteFromHash( 'assets', 'WebGUI::Asset::Wobject::Article' );
314+
unlike(
315+
my $got = $root->www_editMetaDataField(),
316+
qr/WebGUI::Asset::Wobject::Article/,
317+
'article was (temporarily) not in config and should not appear in form'
318+
);
319+
# Restore config:
320+
$session->config->addToHash( 'assets', 'WebGUI::Asset::Wobject::Article' );
321+
322+
308323
sub buildNameIndex {
309324
my ($fidStruct) = @_;
310325
my $nameStruct;

0 commit comments

Comments
 (0)
Please sign in to comment.