Fix installer crashing b/c function was not available.

This commit is contained in:
Markus Birth 2022-02-14 21:44:38 +01:00
parent 5bd24c2d12
commit 27d91781ee
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A
3 changed files with 33 additions and 25 deletions

View File

@ -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)

View File

@ -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.
*

View File

@ -0,0 +1,31 @@
<?php
// Serendipity
// See LICENSE file for license information.
namespace Serendipity\Database;
class DbTools
{
/**
* 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;
}
}