aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-02-10 19:45:08 +0000
committerMario <mario@mariovavti.com>2022-02-10 19:45:08 +0000
commit521c9eb5660df0a954f68499b905f8dc1958bbb3 (patch)
treee075212a0fcb3037b3b8b9a3fb409ea8172d40f4
parent8e79a81b8879b38c06ce3f7a211b87e838773f60 (diff)
parent35877b13825b2c3db44ff89977344b84f8e21d9a (diff)
downloadvolse-hubzilla-521c9eb5660df0a954f68499b905f8dc1958bbb3.tar.gz
volse-hubzilla-521c9eb5660df0a954f68499b905f8dc1958bbb3.tar.bz2
volse-hubzilla-521c9eb5660df0a954f68499b905f8dc1958bbb3.zip
Merge branch 'dev'
-rw-r--r--Zotlabs/Module/Setup.php14
-rw-r--r--Zotlabs/Web/SessionHandler.php2
-rw-r--r--boot.php9
-rw-r--r--include/dba/dba_driver.php12
-rw-r--r--include/dba/dba_pdo.php6
5 files changed, 29 insertions, 14 deletions
diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php
index ca8c19600..04b31e27b 100644
--- a/Zotlabs/Module/Setup.php
+++ b/Zotlabs/Module/Setup.php
@@ -69,17 +69,22 @@ class Setup extends \Zotlabs\Web\Controller {
$dbpass = ((isset($_POST['dbpass'])) ? trim($_POST['dbpass']) : '');
$dbdata = ((isset($_POST['dbdata'])) ? trim($_POST['dbdata']) : '');
$dbtype = ((isset($_POST['dbtype'])) ? intval(trim($_POST['dbtype'])) : 0);
+
$phpath = ((isset($_POST['phpath'])) ? trim($_POST['phpath']) : '');
$adminmail = ((isset($_POST['adminmail'])) ? trim($_POST['adminmail']) : '');
$siteurl = ((isset($_POST['siteurl'])) ? trim($_POST['siteurl']) : '');
+ if (empty($db_charset)) {
+ $db_charset = ((intval($db_type) === 0) ? 'utf8mb4' : 'UTF8');
+ }
+
// $siteurl should not have a trailing slash
$siteurl = rtrim($siteurl,'/');
require_once('include/dba/dba_driver.php');
- $db = \DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true);
+ $db = \DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, $db_charset, true);
if(! \DBA::$dba->connected) {
echo 'Database Connect failed: ' . \DBA::$dba->error;
@@ -94,11 +99,16 @@ class Setup extends \Zotlabs\Web\Controller {
$dbpass = ((isset($_POST['dbpass'])) ? trim($_POST['dbpass']) : '');
$dbdata = ((isset($_POST['dbdata'])) ? trim($_POST['dbdata']) : '');
$dbtype = ((isset($_POST['dbtype'])) ? intval(trim($_POST['dbtype'])) : 0);
+
$phpath = ((isset($_POST['phpath'])) ? trim($_POST['phpath']) : '');
$timezone = ((isset($_POST['timezone'])) ? trim($_POST['timezone']) : '');
$adminmail = ((isset($_POST['adminmail'])) ? trim($_POST['adminmail']) : '');
$siteurl = ((isset($_POST['siteurl'])) ? trim($_POST['siteurl']) : '');
+ if (empty($db_charset)) {
+ $db_charset = ((intval($db_type) === 0) ? 'utf8mb4' : 'UTF8');
+ }
+
if($siteurl != z_root()) {
$test = z_fetch_url($siteurl."/setup/testrewrite");
if((! $test['success']) || ($test['body'] != 'ok')) {
@@ -112,7 +122,7 @@ class Setup extends \Zotlabs\Web\Controller {
if(! isset(\DBA::$dba->connected)) {
// connect to db
- $db = \DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true);
+ $db = \DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, $db_charset, true);
}
if(! isset(\DBA::$dba->connected)) {
diff --git a/Zotlabs/Web/SessionHandler.php b/Zotlabs/Web/SessionHandler.php
index 5af646151..6beb36795 100644
--- a/Zotlabs/Web/SessionHandler.php
+++ b/Zotlabs/Web/SessionHandler.php
@@ -86,7 +86,7 @@ class SessionHandler implements \SessionHandlerInterface {
}
- function gc($expire) : bool {
+ function gc($expire) : int {
q("DELETE FROM session WHERE expire < %d", dbesc(time()));
return true;
}
diff --git a/boot.php b/boot.php
index 30e2e3983..80abc8264 100644
--- a/boot.php
+++ b/boot.php
@@ -664,12 +664,17 @@ function sys_boot() {
require_once('include/dba/dba_driver.php');
if (!App::$install) {
- DBA::dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, App::$install);
+
+ if (empty($db_charset)) {
+ $db_charset = ((intval($db_type) === 0) ? 'utf8mb4' : 'UTF8');
+ }
+
+ DBA::dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, $db_charset, App::$install);
if (!DBA::$dba->connected) {
system_unavailable();
}
- unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type);
+ unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, $db_charset);
/*
* Load configs from db. Overwrite configs from .htconfig.php
diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php
index b96601fec..152be7f88 100644
--- a/include/dba/dba_driver.php
+++ b/include/dba/dba_driver.php
@@ -38,7 +38,7 @@ class DBA {
* @param bool $install Defaults to false
* @return null|dba_driver A database driver object (dba_pdo) or null if no driver found.
*/
- static public function dba_factory($server,$port,$user,$pass,$db,$dbtype,$install = false) {
+ static public function dba_factory($server,$port,$user,$pass,$db,$dbtype,$db_charset,$install = false) {
self::$dba = null;
self::$dbtype = intval($dbtype);
@@ -65,7 +65,7 @@ class DBA {
}
require_once('include/dba/dba_pdo.php');
- self::$dba = new dba_pdo($server,self::$scheme,$port,$user,$pass,$db,$install);
+ self::$dba = new dba_pdo($server,self::$scheme,$port,$user,$pass,$db,$db_charset,$install);
define('NULL_DATE', self::$null_date);
define('ACTIVE_DBTYPE', self::$dbtype);
@@ -105,7 +105,7 @@ abstract class dba_driver {
* @param string $db database name
* @return bool
*/
- abstract function connect($server, $scheme, $port, $user, $pass, $db);
+ abstract function connect($server, $scheme, $port, $user, $pass, $db, $db_charset);
/**
* @brief Perform a DB query with the SQL statement $sql.
@@ -139,11 +139,11 @@ abstract class dba_driver {
*/
abstract function getdriver();
- function __construct($server, $scheme, $port, $user,$pass,$db,$install = false) {
- if(($install) && (! $this->install($server, $scheme, $port, $user, $pass, $db))) {
+ function __construct($server, $scheme, $port, $user,$pass,$db,$db_charset,$install = false) {
+ if(($install) && (! $this->install($server, $scheme, $port, $user, $pass, $db, $db_charset))) {
return;
}
- $this->connect($server, $scheme, $port, $user, $pass, $db);
+ $this->connect($server, $scheme, $port, $user, $pass, $db, $db_charset);
}
function get_null_date() {
diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php
index 2137ca0cc..c8a1b6c85 100644
--- a/include/dba/dba_pdo.php
+++ b/include/dba/dba_pdo.php
@@ -14,7 +14,7 @@ class dba_pdo extends dba_driver {
* {@inheritDoc}
* @see dba_driver::connect()
*/
- function connect($server, $scheme, $port, $user, $pass, $db) {
+ function connect($server, $scheme, $port, $user, $pass, $db, $db_charset) {
$this->driver_dbtype = $scheme;
@@ -28,10 +28,10 @@ class dba_pdo extends dba_driver {
$dsn .= ';dbname=' . $db;
if ($this->driver_dbtype === 'mysql') {
- $dsn .= ';charset=utf8mb4';
+ $dsn .= ';charset=' . $db_charset;
}
else {
- $dsn .= ";options='--client_encoding=UTF8'";
+ $dsn .= ";options='--client_encoding=" . $db_charset . "'";
}
try {