From 5839034e8fe23582820de294e3488e8c2af18eb4 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Tue, 6 Mar 2018 23:07:00 -0600 Subject: [PATCH] Fix egg copy from, closes #995 --- CHANGELOG.md | 1 + app/Models/Egg.php | 42 +++++++++++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 926da0d20..ac930b8c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. ### Fixed * Fixes a UI error when attempting to change the default Nest and Egg for an existing server. * Correct permissions check in UI to allow subusers with permission to `view-allocations` the ability to actually see the sidebar link. +* Fixes improper behavior when marking an egg as copying the configuration from another. ### Changed * Panel now throws proper 504: Gateway Timeout errors on server listing when daemon is offline. diff --git a/app/Models/Egg.php b/app/Models/Egg.php index c9b2d9767..ade28239d 100644 --- a/app/Models/Egg.php +++ b/app/Models/Egg.php @@ -113,7 +113,11 @@ class Egg extends Model implements CleansAttributes, ValidableContract */ public function getCopyScriptInstallAttribute() { - return (is_null($this->copy_script_from)) ? $this->script_install : $this->scriptFrom->script_install; + if (! is_null($this->script_install) || is_null($this->copy_script_from)) { + return $this->script_install; + } + + return $this->scriptFrom->script_install; } /** @@ -124,7 +128,11 @@ class Egg extends Model implements CleansAttributes, ValidableContract */ public function getCopyScriptEntryAttribute() { - return (is_null($this->copy_script_from)) ? $this->script_entry : $this->scriptFrom->script_entry; + if (! is_null($this->script_entry) || is_null($this->copy_script_from)) { + return $this->script_entry; + } + + return $this->scriptFrom->script_entry; } /** @@ -135,7 +143,11 @@ class Egg extends Model implements CleansAttributes, ValidableContract */ public function getCopyScriptContainerAttribute() { - return (is_null($this->copy_script_from)) ? $this->script_container : $this->scriptFrom->script_container; + if (! is_null($this->script_container) || is_null($this->copy_script_from)) { + return $this->script_container; + } + + return $this->scriptFrom->script_container; } /** @@ -145,7 +157,11 @@ class Egg extends Model implements CleansAttributes, ValidableContract */ public function getInheritConfigFilesAttribute() { - return is_null($this->config_from) ? $this->config_files : $this->configFrom->config_files; + if (! is_null($this->config_files) || is_null($this->config_from)) { + return $this->config_files; + } + + return $this->configFrom->config_files; } /** @@ -155,7 +171,11 @@ class Egg extends Model implements CleansAttributes, ValidableContract */ public function getInheritConfigStartupAttribute() { - return is_null($this->config_from) ? $this->config_startup : $this->configFrom->config_startup; + if (! is_null($this->config_startup) || is_null($this->config_from)) { + return $this->config_startup; + } + + return $this->configFrom->config_startup; } /** @@ -165,7 +185,11 @@ class Egg extends Model implements CleansAttributes, ValidableContract */ public function getInheritConfigLogsAttribute() { - return is_null($this->config_from) ? $this->config_logs : $this->configFrom->config_logs; + if (! is_null($this->config_logs) || is_null($this->config_from)) { + return $this->config_logs; + } + + return $this->configFrom->config_logs; } /** @@ -175,7 +199,11 @@ class Egg extends Model implements CleansAttributes, ValidableContract */ public function getInheritConfigStopAttribute() { - return is_null($this->config_from) ? $this->config_stop : $this->configFrom->config_stop; + if (! is_null($this->config_stop) || is_null($this->config_from)) { + return $this->config_stop; + } + + return $this->configFrom->config_stop; } /**