CRM-19164 use exception rather than assert (for HHVM)
authoreileen <emcnaughton@wikimedia.org>
Mon, 1 Aug 2016 23:05:02 +0000 (11:05 +1200)
committereileen <emcnaughton@wikimedia.org>
Mon, 1 Aug 2016 23:05:09 +0000 (11:05 +1200)
Civi/Core/Transaction/Frame.php

index f3ad3fc4cfbe8c504b1e33fa314c4dd450864f24..d12de55fa092c2f644d17f34f69c57fbdecff5f5 100644 (file)
@@ -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) {