diff --git a/src/opnsense/mvc/app/library/OPNsense/Firewall/Util.php b/src/opnsense/mvc/app/library/OPNsense/Firewall/Util.php index f5f7bfbd6..36f6d85c0 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Firewall/Util.php +++ b/src/opnsense/mvc/app/library/OPNsense/Firewall/Util.php @@ -74,6 +74,16 @@ class Util return false; } + /** + * use provided alias object instead of creating one. When modifying multiple aliases referencing each other + * we need to use the same object for validations. + * @param Alias $alias object to link + */ + public static function attachAliasObject($alias) + { + self::$aliasObject = $alias; + } + /** * check if name exists in alias config section * @param string $name name diff --git a/src/opnsense/mvc/app/models/OPNsense/Firewall/Alias.php b/src/opnsense/mvc/app/models/OPNsense/Firewall/Alias.php index c8a577d04..d0f83d7ce 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Firewall/Alias.php +++ b/src/opnsense/mvc/app/models/OPNsense/Firewall/Alias.php @@ -31,6 +31,7 @@ namespace OPNsense\Firewall; use OPNsense\Base\BaseModel; use OPNsense\Core\Config; +use OPNsense\Firewall\Util; /** * Class Alias @@ -133,6 +134,7 @@ class Alias extends BaseModel */ public function refactor($oldname, $newname) { + Util::attachAliasObject($this); // replace in legacy config foreach ($this->searchConfig($oldname) as $item) { $item[2][0] = $newname;