Bug 23151: Tweak to use the new database structure
[koha.git] / Koha / Patron / Modifications.pm
index 646d112..e29079c 100644 (file)
@@ -30,6 +30,7 @@ use Koha::Patron::Attribute;
 use Koha::Patron::Modification;
 
 use JSON;
+use List::Util qw /any none/;
 
 use base qw(Koha::Objects);
 
@@ -116,7 +117,12 @@ sub pending {
 
     my @m;
     while ( my $row = $sth->fetchrow_hashref() ) {
+        my @changed_keys = split /,/, $row->{changed_fields};
         foreach my $key ( keys %$row ) {
+            if ($key eq 'changed_fields') {
+                delete $row->{$key};
+                next;
+            }
             if ( defined $row->{$key} && $key eq 'extended_attributes' ) {
                 my $attributes = from_json( $row->{$key} );
                 my @pending_attributes;
@@ -132,9 +138,7 @@ sub pending {
 
                 $row->{$key} = \@pending_attributes;
             }
-            if ( $key eq 'dateofbirth' and not defined $row->{$key}) {
-                $row->{$key} = '';
-            } else {
+            if (none { $_ eq $key } @changed_keys) {
                 delete $row->{$key} unless defined $row->{$key};
             }
         }