Code Duplication    Length = 28-28 lines in 2 locations

src/voku/db/DB.php 1 location

@@ 782-809 (lines=28) @@
779
   *
780
   * @return bool
781
   */
782
  protected function queryErrorHandling($errorMsg, $sql, $sqlParams = false)
783
  {
784
    if ($errorMsg === 'DB server has gone away' || $errorMsg === 'MySQL server has gone away') {
785
      static $RECONNECT_COUNTER;
786
787
      // exit if we have more then 3 "DB server has gone away"-errors
788
      if ($RECONNECT_COUNTER > 3) {
789
        $this->_debug->mailToAdmin('SQL-Fatal-Error', $errorMsg . ":\n<br />" . $sql, 5);
790
        throw new \Exception($errorMsg);
791
      }
792
793
      $this->_debug->mailToAdmin('SQL-Error', $errorMsg . ":\n<br />" . $sql);
794
795
      // reconnect
796
      $RECONNECT_COUNTER++;
797
      $this->reconnect(true);
798
799
      // re-run the current query
800
      return $this->query($sql, $sqlParams);
801
    }
802
803
    $this->_debug->mailToAdmin('SQL-Warning', $errorMsg . ":\n<br />" . $sql);
804
805
    // this query returned an error, we must display it (only for dev) !!!
806
    $this->_debug->displayError($errorMsg . ' | ' . $sql);
807
808
    return false;
809
  }
810
811
  /**
812
   * Reconnect to the MySQL-Server.

src/voku/db/Prepare.php 1 location

@@ 416-443 (lines=28) @@
413
   *
414
   * @return bool
415
   */
416
  private function queryErrorHandling($errorMsg, $sql)
417
  {
418
    if ($errorMsg === 'DB server has gone away' || $errorMsg === 'MySQL server has gone away') {
419
      static $reconnectCounter;
420
421
      // exit if we have more then 3 "DB server has gone away"-errors
422
      if ($reconnectCounter > 3) {
423
        $this->_debug->mailToAdmin('SQL-Fatal-Error', $errorMsg . ":\n<br />" . $sql, 5);
424
        throw new \Exception($errorMsg);
425
      }
426
427
      $this->_debug->mailToAdmin('SQL-Error', $errorMsg . ":\n<br />" . $sql);
428
429
      // reconnect
430
      $reconnectCounter++;
431
      $this->_db->reconnect(true);
432
433
      // re-run the current query
434
      return $this->execute();
435
    }
436
437
    $this->_debug->mailToAdmin('SQL-Warning', $errorMsg . ":\n<br />" . $sql);
438
439
    // this query returned an error, we must display it (only for dev) !!!
440
    $this->_debug->displayError($errorMsg . ' | ' . $sql);
441
442
    return false;
443
  }
444
445
}
446