fix(legacy): sanitize track_type_id when updating file (#2003)

Fixes #2000
This commit is contained in:
Jonas L 2022-07-27 09:52:09 +02:00 committed by GitHub
parent e6d24333cb
commit f137be09a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -49,6 +49,9 @@ class FileDataHelper
// This will convert floats to ints too.
$data['bpm'] = intval($data['bpm']);
}
if (array_key_exists('track_type_id', $data)) {
$data['track_type_id'] = intval($data['track_type_id']);
}
}
/**

View File

@ -229,6 +229,12 @@ class Application_Model_StoredFile
if ($dbColumn == 'track_number' && empty($mdValue)) {
$mdValue = null;
}
// We need to set track_type_id to null if it is an empty string or 0
if ($dbColumn == 'track_type_id' && ($mdValue == 0 || empty($mdValue))) {
$mdValue = null;
}
$this->_file->{$method}($mdValue);
}
}