From d133bc2afba0cb0627a93df50b7ce75a1ceaf0f1 Mon Sep 17 00:00:00 2001 From: ligc Date: Wed, 13 May 2009 08:48:27 +0000 Subject: [PATCH] fix for bug 2790619 chdef add member to the group failed, a regular expression match issue in defch git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3367 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/DBobjUtils.pm | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm index 1ec00a12b..860c01d7f 100644 --- a/perl-xCAT/xCAT/DBobjUtils.pm +++ b/perl-xCAT/xCAT/DBobjUtils.pm @@ -1001,13 +1001,18 @@ sub setobjdefs # add new to existing - at the end - comma separated if (defined($DBattrvals{$objname}{$attr_name})) { - # if it's not already in the list! - if (!($DBattrvals{$objname}{$attr_name} =~ /\b$objhash{$objname}{$attr_name}\b/) ) - { - $val = "$DBattrvals{$objname}{$attr_name},$objhash{$objname}{$attr_name}"; - } else { - $val = "$DBattrvals{$objname}{$attr_name}"; - } + # add the attr into the list if it's not already in the list! + # and avoid the duplicate values + my @DBattrarray = split(',', $DBattrvals{$objname}{$attr_name}); + my @objhasharray = split(',', $objhash{$objname}{$attr_name}); + foreach my $objattr (@objhasharray) + { + if (!grep(/^\Q$objattr\E$/, @DBattrarray)) + { + push @DBattrarray, $objattr; + } + } + $val = join(',', @DBattrarray); } else {