Bug 3212 Force leader 9 position to 'a' for new biblios
authorFrédéric Demians <f.demians@tamil.fr>
Wed, 5 Jan 2011 10:45:52 +0000 (11:45 +0100)
committerChris Cormack <chrisc@catalyst.net.nz>
Thu, 3 Feb 2011 09:15:25 +0000 (22:15 +1300)
When Creating a new biblio record, if the cataloguer doesn't use the leader
plugin, a biblio record can be saved with a leader not containing a 'a' in 9
position. If the biblio contains UTF-8 characters, its decoding can fail.

This issue applies to MARC-21 not UNIMARC.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
C4/Biblio.pm

index 7eb3124..c3615ba 100644 (file)
@@ -1924,8 +1924,13 @@ sub TransformHtmlToMarc {
             if ( $tag < 10 ) {                              # no code for theses fields
                                                             # in MARC editor, 000 contains the leader.
                 if ( $tag eq '000' ) {
-                    $record->leader( $cgi->param( $params->[ $j + 1 ] ) ) if length( $cgi->param( $params->[ $j + 1 ] ) ) == 24;
-
+                    # Force a fake leader even if not provided to avoid crashing
+                    # during decoding MARC record containing UTF-8 characters
+                    $record->leader(
+                        length( $cgi->param($params->[$j+1]) ) == 24
+                        ? $cgi->param( $params->[ $j + 1 ] )
+                        : '     nam a22        4500'
+                    ;
                     # between 001 and 009 (included)
                 } elsif ( $cgi->param( $params->[ $j + 1 ] ) ne '' ) {
                     $newfield = MARC::Field->new( $tag, $cgi->param( $params->[ $j + 1 ] ), );