From 078c5785ddf09dfaac3c3c01e7848664685a69ee Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 13 Jun 2021 12:40:06 +0200 Subject: [PATCH] fix unit tests on php < 7.3 --- lib/Data/Database.php | 26 ++++++++++++++++---------- tst/ModelTest.php | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/Data/Database.php b/lib/Data/Database.php index dea1be6d..1d1327fd 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -233,11 +233,14 @@ class Database extends AbstractData } self::$_cache[$pasteid] = false; - $paste = self::_select( - 'SELECT * FROM ' . self::_sanitizeIdentifier('paste') . - ' WHERE dataid = ?', array($pasteid), true - ); - + try { + $paste = self::_select( + 'SELECT * FROM ' . self::_sanitizeIdentifier('paste') . + ' WHERE dataid = ?', array($pasteid), true + ); + } catch (Exception $e) { + $paste = false; + } if ($paste === false) { return false; } @@ -643,15 +646,18 @@ class Database extends AbstractData * @access private * @static * @param string $key - * @throws PDOException * @return string */ private static function _getConfig($key) { - $row = self::_select( - 'SELECT value FROM ' . self::_sanitizeIdentifier('config') . - ' WHERE id = ?', array($key), true - ); + try { + $row = self::_select( + 'SELECT value FROM ' . self::_sanitizeIdentifier('config') . + ' WHERE id = ?', array($key), true + ); + } catch (PDOException $e) { + return ''; + } return $row ? $row['value'] : ''; } diff --git a/tst/ModelTest.php b/tst/ModelTest.php index 327e7013..94321244 100644 --- a/tst/ModelTest.php +++ b/tst/ModelTest.php @@ -259,6 +259,7 @@ class ModelTest extends PHPUnit_Framework_TestCase $paste = $model->getPaste(); $paste->setData($pasteData); $paste->store(); + $paste->exists(); $db = new PDO( $options['model_options']['dsn'],