SAAS-439: Genres longer than 64 characters cause Media API exception
* Truncate the genre field in the Media API
This commit is contained in:
parent
8432799b9a
commit
091be8cea3
|
@ -222,6 +222,7 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
$requestData = json_decode($this->getRequest()->getRawBody(), true);
|
||||
$whiteList = $this->removeBlacklistedFieldsFromRequestData($requestData);
|
||||
$whiteList = $this->stripTimeStampFromYearTag($whiteList);
|
||||
$whiteList = $this->truncateGenreTag($whiteList);
|
||||
|
||||
if (!$this->validateRequestData($file, $whiteList)) {
|
||||
$file->save();
|
||||
|
@ -502,6 +503,20 @@ class Rest_MediaController extends Zend_Rest_Controller
|
|||
}
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
|
||||
/** The genre tag in our cc_files schema is currently a varchar(64). It's possible for MP3 genre tags
|
||||
* to be longer than that, so we have to truncate longer genres. (We've seen ridiculously long genre tags.)
|
||||
* @param string array $metadata
|
||||
*/
|
||||
private function truncateGenreTag($metadata)
|
||||
{
|
||||
if (isset($metadata["genre"]))
|
||||
{
|
||||
if (strlen($metadata["genre"]) >= 64) {
|
||||
$metadata["genre"] = substr($metadata["genre"], 0, 64);
|
||||
}
|
||||
}
|
||||
return $metadata;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue