Ticket #3659 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Can't delete division using batch edit

Reported by: tmb Owned by:
Priority: Customer Report Milestone: EPrints 3.2.x (general bugs/features for 3.2)
Component: - Version: 3.1
Severity: normal Keywords:
Cc:

Description

"Delete values matching" gives a success message but doesn't actually remove the division.

Change History

Changed 4 years ago by tdb01r

Works in v3.2 (which is a complete re-write though).

Changed 4 years ago by tmb

 elsif( $action eq "delete" )
 {
     if( $field->get_property( "multiple" ) )
     {
         my $values = $object->get_value( $fieldname );
         my @$values = grep { cmp_deeply($value, $_) != 0 } @$values;
         $object->set_value( $fieldname, $values );

$value is an arrayref to $object->{data}->{$fieldname}

=> when $value is changed, $object->{data}->{$fieldname} gets changed.

=> when DataObj::set_value_raw compares $value and $object->{data}->{$fieldname} it doesn't think the value of $fieldname has changed.

Fix:

my $values = $object->get_value( $fieldname );
my @new_values = grep { cmp_deeply($value, $_) != 0 } @$values;
$object->set_value( $fieldname, \@new_values );

Changed 4 years ago by tmb

Above comment should read $values not $value:

$values is an arrayref to $object->{data}->{$fieldname}

=> when $values is changed, $object->{data}->{$fieldname} gets changed.

=> when DataObj::set_value_raw compares $values and $object->{data}->{$fieldname} it doesn't think the value of $fieldname has changed.

Changed 4 years ago by tdb01r

  • status changed from new to closed
  • resolution set to fixed

This is now:

my $values = EPrints::Utils::clone( $orig_value );
@$values = grep { cmp_deeply($value, $_) != 0 } @$values;
$field->set_value( $dataobj, $values );
Note: See TracTickets for help on using tickets.