#1524 -- Always clear ports before reassigning for cloned stations.
This commit is contained in:
parent
1b0e7cdde6
commit
54c9e52259
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
]);
|
||||
|
|
Loading…
Reference in New Issue