mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-24 22:18:00 +01:00
#86: Fixed track uploading SQL errors
This commit is contained in:
parent
0427658dbf
commit
45dae68497
1 changed files with 20 additions and 0 deletions
|
@ -95,10 +95,30 @@ class ParseTrackTagsCommand extends CommandBase
|
||||||
$this->track->is_downloadable = $this->input['is_downloadable'] ?? true;
|
$this->track->is_downloadable = $this->input['is_downloadable'] ?? true;
|
||||||
$this->track->is_listed = $this->input['is_listed'] ?? true;
|
$this->track->is_listed = $this->input['is_listed'] ?? true;
|
||||||
|
|
||||||
|
$this->track = $this->unsetNullVariables($this->track);
|
||||||
|
|
||||||
$this->track->save();
|
$this->track->save();
|
||||||
return CommandResponse::succeed();
|
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.
|
* Returns the ID of the given genre, creating it if necessary.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue