From 0dbbb8e7dc8cf616ffe40d51c211ec0e9c4b06ac Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 2 Aug 2016 11:05:02 +1200 Subject: [PATCH] CRM-19164 use exception rather than assert (for HHVM) --- Civi/Core/Transaction/Frame.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Civi/Core/Transaction/Frame.php b/Civi/Core/Transaction/Frame.php index f3ad3fc4cf..d12de55fa0 100644 --- a/Civi/Core/Transaction/Frame.php +++ b/Civi/Core/Transaction/Frame.php @@ -117,8 +117,16 @@ class Frame { $this->doCommit = FALSE; } + /** + * Begin frame processing. + * + * @throws \CRM_Core_Exception + */ public function begin() { - assert('$this->state === self::F_NEW'); + if ($this->state !== self::F_NEW) { + throw new \CRM_Core_Exception('State is not F_NEW'); + }; + $this->state = self::F_ACTIVE; if ($this->beginStmt) { $this->dao->query($this->beginStmt); @@ -126,14 +134,20 @@ class Frame { } /** + * Finish frame processing. + * * @param int $newState - * @void + * + * @throws \CRM_Core_Exception */ public function finish($newState = self::F_DONE) { if ($this->state == self::F_FORCED) { return; } - assert('$this->state === self::F_ACTIVE'); + if ($this->state !== self::F_ACTIVE) { + throw new \CRM_Core_Exception('State is not F_ACTIVE'); + }; + $this->state = $newState; if ($this->doCommit) { -- 2.25.1