From 1540f6a7155aec669ae47df8782793b3576daeb4 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Tue, 28 Nov 2023 22:39:29 +0100 Subject: [PATCH] Prevent FKEY issue removing already lent object closes #1746 --- lib/GaletteObjectsLend/Repository/Objects.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/GaletteObjectsLend/Repository/Objects.php b/lib/GaletteObjectsLend/Repository/Objects.php index 1adc2ec..0899772 100644 --- a/lib/GaletteObjectsLend/Repository/Objects.php +++ b/lib/GaletteObjectsLend/Repository/Objects.php @@ -183,6 +183,14 @@ public function removeObjects(array $ids) try { $this->zdb->connection->beginTransaction(); + $update = $this->zdb->update(LEND_PREFIX . self::TABLE); + $update->set(['rent_id' => null]); + $update->where->in( + self::PK, + $ids + ); + $this->zdb->execute($update); + $delete = $this->zdb->delete(LEND_PREFIX . LendRent::TABLE); $delete->where->in( self::PK,