From 27d91781ee941fb41779a2cf73a2d22ed6aaadd3 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Mon, 14 Feb 2022 21:44:38 +0100 Subject: [PATCH] Fix installer crashing b/c function was not available. --- include/db/db.inc.php | 5 ++-- lib/Serendipity/Database/DbAbstract.php | 22 ------------------ lib/Serendipity/Database/DbTools.php | 31 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 25 deletions(-) create mode 100644 lib/Serendipity/Database/DbTools.php diff --git a/include/db/db.inc.php b/include/db/db.inc.php index ed805a33..b13ef6ce 100644 --- a/include/db/db.inc.php +++ b/include/db/db.inc.php @@ -6,6 +6,7 @@ // FIXME: THIS IS A SHIM FOR BACKWARDS COMPATIBILITY - REMOVE WHEN NO LONGER NEEDED use Serendipity\Database\DbFactory; +use Serendipity\Database\DbTools; // SQLite3 only fetches by assoc, we will emulate the other result types define(SQLITE3_ASSOC, 0); @@ -42,9 +43,7 @@ function serendipity_db_insert($table, $values, $action = 'execute') function serendipity_db_bool($val) { - global $serendipity; - $db = DbFactory::createFromConfig($serendipity); - return $db->bool($val); + return DbTools::bool($val); } function serendipity_db_get_interval($val, $ival = 900) diff --git a/lib/Serendipity/Database/DbAbstract.php b/lib/Serendipity/Database/DbAbstract.php index f021ddbf..77a824c6 100644 --- a/lib/Serendipity/Database/DbAbstract.php +++ b/lib/Serendipity/Database/DbAbstract.php @@ -229,28 +229,6 @@ abstract class DbAbstract } } - /** - * Check whether an input value corresponds to a TRUE/FALSE option in the SQL database. - * - * Because older DBs could not store TRUE/FALSE values to be restored into a PHP variable, - * this function tries to detect what the return code of a SQL column is, and convert it - * to a PHP native boolean. - * - * Values that will be recognized as TRUE are 'true', 't' and '1'. - * - * @access public - * @param string input value to compare - * @return boolean boolean conversion of the input value - */ - public function bool($val) - { - if (($val === true) || ($val == 'true') || ($val == 't') || ($val == '1')) { - return true; - } - #elseif (($val === false || $val == 'false' || $val == 'f')) - return false; - } - /** * Prepares a Serendipity query input to fully valid SQL. Replaces certain "template" variables. * diff --git a/lib/Serendipity/Database/DbTools.php b/lib/Serendipity/Database/DbTools.php new file mode 100644 index 00000000..f598f52c --- /dev/null +++ b/lib/Serendipity/Database/DbTools.php @@ -0,0 +1,31 @@ +