| 1108 | | if ($rawmeta =~ m/^SERG/) { |
| 1109 | | # deserialize |
| 1110 | | my $metadataref = $ser->unserialize($rawmeta); |
| 1111 | | if ($metadataref) { |
| 1112 | | my $metadata = $$metadataref; |
| 1113 | | my $obj = $class->load( { id => $id }, { no_class => 1, fetchonly => [ 'id', ( $class_type ? ( $class->properties->{class_column} ) : () ) ] }); |
| 1114 | | if ($obj) { |
| 1115 | | my $changed = 0; |
| 1116 | | foreach my $metaname (keys %$metadata) { |
| 1117 | | my $metavalue = $metadata->{$metaname}; |
| 1118 | | if ($metaname eq 'customfields') { |
| 1119 | | next unless $cfclass; |
| 1120 | | |
| 1121 | | # extra work for custom fields; a hash into itself |
| 1122 | | my $cfdata = $metavalue; |
| 1123 | | next unless ref $cfdata eq 'HASH'; |
| 1124 | | |
| 1125 | | foreach my $cfname (keys %$cfdata) { |
| 1126 | | my $cfvalue = $cfdata->{$cfname}; |
| 1127 | | my $cftype = $type; |
| 1128 | | if ($class_type) { |
| 1129 | | $cftype = $obj->class_type; |
| | 1108 | if (defined $rawmeta) { |
| | 1109 | push @ids, $id; |
| | 1110 | if ($rawmeta =~ m/^SERG/) { |
| | 1111 | # deserialize |
| | 1112 | my $metadataref = $ser->unserialize($rawmeta); |
| | 1113 | if ($metadataref) { |
| | 1114 | my $metadata = $$metadataref; |
| | 1115 | my $obj = $class->load( { id => $id }, { no_class => 1, |
| | 1116 | fetchonly => [ 'id', |
| | 1117 | ( $class_type ? ( $class->properties->{class_column} ) : () ) |
| | 1118 | ] |
| | 1119 | }); |
| | 1120 | if ($obj) { |
| | 1121 | foreach my $metaname (keys %$metadata) { |
| | 1122 | my $metavalue = $metadata->{$metaname}; |
| | 1123 | if ($metaname eq 'customfields') { |
| | 1124 | next unless $cfclass; |
| | 1125 | |
| | 1126 | # extra work for custom fields; |
| | 1127 | # a hash into itself |
| | 1128 | my $cfdata = $metavalue; |
| | 1129 | next unless ref $cfdata eq 'HASH'; |
| | 1130 | |
| | 1131 | foreach my $cfname (keys %$cfdata) { |
| | 1132 | my $cfvalue = $cfdata->{$cfname}; |
| | 1133 | my $cftype = $type; |
| | 1134 | if ($class_type) { |
| | 1135 | $cftype = $obj->class_type; |
| | 1136 | } |
| | 1137 | |
| | 1138 | # make sure CustomFields::Field exists |
| | 1139 | my $fld = $fields{$cfname}{$cftype} ||= $cfclass->load({ basename => $cfname, obj_type => $cftype }); |
| | 1140 | next unless $fld; |
| | 1141 | |
| | 1142 | $self->_save_meta($obj, |
| | 1143 | 'field.' . $cfname, $cfvalue); |