From 844946b706ffe4d1bb80b9d478b2f423d18b95fd Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 13 Sep 2018 08:29:49 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#681 where Fieldtype exceptions getting caught when saving page, which could interfere with InnoDB transactions when Fieldtype throws an Exception --- wire/core/PagesEditor.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wire/core/PagesEditor.php b/wire/core/PagesEditor.php index 2dc6aebe..85937260 100644 --- a/wire/core/PagesEditor.php +++ b/wire/core/PagesEditor.php @@ -282,6 +282,7 @@ class PagesEditor extends Wire { * - Populates any default values for fields. * * @param Page $page + * @throws \Exception|WireException|\PDOException if failure occurs while in DB transaction * */ public function setupNew(Page $page) { @@ -327,6 +328,7 @@ class PagesEditor extends Wire { } } catch(\Exception $e) { $this->trackException($e, false, true); + if($this->wire('database')->inTransaction()) throw $e; } } } @@ -598,6 +600,7 @@ class PagesEditor extends Wire { * @param bool $isNew * @param array $options * @return bool + * @throws \Exception|WireException|\PDOException If any field-saving failure occurs while in a DB transaction * */ protected function savePageFinish(Page $page, $isNew, array $options) { @@ -647,6 +650,7 @@ class PagesEditor extends Wire { } catch(\Exception $e) { $error = sprintf($this->_('Error saving field "%s"'), $name) . ' - ' . $e->getMessage(); $this->trackException($e, true, $error); + if($this->wire('database')->inTransaction()) throw $e; } } }