From b4564958a1142fbf2ef28f13ee8839806a78698b Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Sun, 10 Feb 2019 11:03:52 +0000 Subject: [PATCH] phpdoc; touch sqlite file before trying to use it in tests --- functions.inc.php | 19 +++++++++---------- tests/bootstrap.php | 3 +++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/functions.inc.php b/functions.inc.php index 5350f823..a1170db5 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -1430,17 +1430,10 @@ EOF; * db_connect * Action: Makes a connection to the database if it doesn't exist * Call: db_connect () - * Optional parameter: $ignore_errors = TRUE, used by setup.php * * Return value: - * a) without $ignore_errors or $ignore_errors == 0 - * - $link - the database connection -OR- - * - call die() in case of connection problems - * b) with $ignore_errors == TRUE - * array($link, $error_text); * - * @param bool $ignore_errors - * @return PDO + * @return \PDO|false */ function db_connect() { list($link, $_) = db_connect_with_errors(); @@ -1450,7 +1443,7 @@ function db_connect() { /** * @param bool $ignore_errors - * @return array + * @return array [PDO link | false, string $error_text]; */ function db_connect_with_errors() { global $CONF; @@ -1462,7 +1455,7 @@ function db_connect_with_errors() { if (isset($link) && $link) { return array($link, $error_text); } - $link = 0; + $link = false; $options = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, @@ -1649,6 +1642,12 @@ function db_query_one($sql, array $values = array()) { } +/** + * @param string $sql e.g. UPDATE foo SET bar = :baz + * @param array $values - parameters for the prepared statement e.g. ['baz' => 1234] + * @param bool $throw_errors + * @return int number of rows affected by the query + */ function db_execute($sql, array $values = array(), $throw_errors = false) { $link = db_connect(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 66828f4d..444feda0 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -11,6 +11,9 @@ $CONF['default_language'] = 'en'; $CONF['language_hook'] = ''; $db_file = dirname(__FILE__) . '/postfixadmin.sqlite.test'; + +touch($db_file); + $CONF['database_type'] = 'sqlite'; $CONF['database_name'] = $db_file;