#1524 -- Always clear ports before reassigning for cloned stations.

This commit is contained in:
Buster Neece 2019-05-19 10:30:44 -05:00
parent 1b0e7cdde6
commit 54c9e52259
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
3 changed files with 21 additions and 3 deletions

View File

@ -541,6 +541,22 @@ class Station
$this->backend_config = $config;
}
/**
* Clear all port assignments for the station (useful after cloning).
*/
public function clearPorts(): void
{
$fe_config = (array)$this->frontend_config;
unset($fe_config['port']);
$this->frontend_config = $fe_config;
$be_config = (array)$this->backend_config;
unset($be_config['dj_port'], $be_config['telnet_port']);
$this->backend_config = $be_config;
}
/**
* Whether the station uses AzuraCast to directly manage the AutoDJ or lets the backend handle it.
*

View File

@ -153,6 +153,8 @@ class StationCloneForm extends StationForm
$new_record->setName($data['name']);
$new_record->setDescription($data['description']);
$new_record->clearPorts();
$new_record->setIsStreamerLive(false);
$new_record->setNeedsRestart(false);
$new_record->setHasStarted(false);

View File

@ -241,7 +241,7 @@ class Configuration
$frontend_config = (array)$station->getFrontendConfig();
$backend_config = (array)$station->getBackendConfig();
if (empty($frontend_config['port']) || $force) {
if ($force || empty($frontend_config['port'])) {
$base_port = $this->getFirstAvailableRadioPort($station);
$station->setFrontendConfig([
@ -251,13 +251,13 @@ class Configuration
$base_port = (int)$frontend_config['port'];
}
if (empty($backend_config['dj_port'])) {
if ($force || empty($backend_config['dj_port'])) {
$station->setBackendConfig([
'dj_port' => $base_port + 5,
]);
}
if (empty($backend_config['telnet_port'])) {
if ($force || empty($backend_config['telnet_port'])) {
$station->setBackendConfig([
'telnet_port' => $base_port + 4,
]);