#86: Fixed track uploading SQL errors

This commit is contained in:
Josef Citrine 2016-07-11 13:00:29 +01:00
parent 0427658dbf
commit 45dae68497

View file

@ -95,10 +95,30 @@ class ParseTrackTagsCommand extends CommandBase
$this->track->is_downloadable = $this->input['is_downloadable'] ?? true;
$this->track->is_listed = $this->input['is_listed'] ?? true;
$this->track = $this->unsetNullVariables($this->track);
$this->track->save();
return CommandResponse::succeed();
}
/**
* If a value is null, remove it! Helps prevent weird SQL errors
*
* @param Track
* @return Track
*/
private function unsetNullVariables($track) {
$vars = $track->getAttributes();
foreach ($vars as $key => $value) {
if ($value == null) {
unset($track->{"$key"});
}
}
return $track;
}
/**
* Returns the ID of the given genre, creating it if necessary.
*