Ignore:
Timestamp:
2023-09-23T18:25:57+12:00 (9 months ago)
Author:
anupama
Message:

Before furthering work on remove-meta-array methods, I want to commit what I think is a fix for something else, but need to run this by Dr Bainbridge. I think the existing set_index_metadata_entry was overriding all existing metadata for a metadataname if prevmetadatavalue was specified but not found. I think this is a destructive operation and is side-effecting code: not what the caller expects. The right solution may have been to do nothing (and may still be to do nothing), but in case there's now some dependency on this behaviour, I'm choosing to accumulate the new value for the specified metadata name. It may still be unnecessary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/cgiactions/modmetadataaction.pm

    r37734 r38190  
    279279        }
    280280
    281         if($found == 0){
    282             $doc_rec->{$metaname} = [ $metavalue ];
     281    if($found == 0){
     282        print STDERR "**** Warning: could not find $prevmetavalue to replace. Appending (accumulating) replacement value.\n";
     283            ##$doc_rec->{$metaname} = [ $metavalue ]; # if prevmetavalue not found, don't overwrite all previous values.
     284        # Accumulate is less destructive. But should the correct behaviour be to not do Anything?
     285
     286        if(defined $doc_rec->{$metaname}) {
     287        push(@{$doc_rec->{$metaname}}, $metavalue); # accumulate the value for that metaname
     288        } else {
     289        $doc_rec->{$metaname} = [ $metavalue ];
     290        }
    283291        }
    284292    }
Note: See TracChangeset for help on using the changeset viewer.