From 3ef4a83f4aaed3fd50031067965ceb0240c304c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 4 May 2026 22:42:18 +0200 Subject: [PATCH] Do not change EDA info of original category or footprint when cloning Fixes #1341. We have to clone the eda info on duplicaion --- src/Entity/Parts/Category.php | 9 +++++++++ src/Entity/Parts/Footprint.php | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/Entity/Parts/Category.php b/src/Entity/Parts/Category.php index 7fca81bc..22f8a3e4 100644 --- a/src/Entity/Parts/Category.php +++ b/src/Entity/Parts/Category.php @@ -208,6 +208,15 @@ class Category extends AbstractPartsContainingDBElement $this->eda_info = new EDACategoryInfo(); } + public function __clone() + { + if ($this->id) { + //Clone EDA info to prevent changes to the original EDA info when changing the cloned category + $this->eda_info = clone $this->eda_info; + } + parent::__clone(); + } + public function getPartnameHint(): string { return $this->partname_hint; diff --git a/src/Entity/Parts/Footprint.php b/src/Entity/Parts/Footprint.php index 6b043562..3d8be686 100644 --- a/src/Entity/Parts/Footprint.php +++ b/src/Entity/Parts/Footprint.php @@ -152,6 +152,15 @@ class Footprint extends AbstractPartsContainingDBElement $this->eda_info = new EDAFootprintInfo(); } + public function __clone() + { + if ($this->id) { + //Clone EDA info to prevent changes to the original EDA info when changing the cloned category + $this->eda_info = clone $this->eda_info; + } + parent::__clone(); + } + /**************************************** * Getters ****************************************/