Bug 11351: (follow-up) ensure itemtypes.sip_media_type is set to NULL when cleared
authorGalen Charlton <gmc@esilibrary.com>
Mon, 28 Apr 2014 18:08:58 +0000 (18:08 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 28 Apr 2014 18:08:58 +0000 (18:08 +0000)
This patch ensures that the sip_media_type is set to NULL
rather than the empty string when it is cleared via item
types administration.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
admin/itemtypes.pl

index df91e7b..87af801 100755 (executable)
@@ -91,6 +91,9 @@ if ($op) {
 
 my $dbh = C4::Context->dbh;
 
+my $sip_media_type = $input->param('sip_media_type');
+undef($sip_media_type) if defined($sip_media_type) and $sip_media_type =~ /^\s*$/;
+
 ################## ADD_FORM ##################################
 # called by default. Used to create form to add or  modify a record
 if ( $op eq 'add_form' ) {
@@ -164,7 +167,7 @@ elsif ( $op eq 'add_validate' ) {
             $input->param('summary'),
             $input->param('checkinmsg'),
             $input->param('checkinmsgtype'),
-            $input->param('sip_media_type'),
+            $sip_media_type,
             $input->param('itemtype')
         );
     }
@@ -188,7 +191,7 @@ elsif ( $op eq 'add_validate' ) {
             $input->param('summary'),
             $input->param('checkinmsg'),
             $input->param('checkinmsgtype'),
-            $input->param('sip_media_type'),
+            $sip_media_type,
         );
     }