Some updates and minor fixes DBMaintainer

This commit is contained in:
fbsanchez 2021-02-01 13:31:42 +01:00
parent 04be237b7a
commit 96c218f21e
4 changed files with 77 additions and 34 deletions

View File

@ -72,17 +72,18 @@ final class Config
$config['history_db_port'],
false
);
ob_get_clean();
}
ob_start();
if ($config['history_db_connection'] !== false) {
$data = \db_get_all_rows_sql(
'SELECT * FROM `tconfig`',
false,
false,
$config['history_db_connection']
);
}
ob_get_clean();
}
if (is_array($data) !== true) {
return [];
@ -119,6 +120,8 @@ final class Config
if (isset(self::$settings[$token]) === true) {
return self::$settings[$token];
}
return $default;
} else {
global $config;

View File

@ -230,12 +230,14 @@ final class DBMaintainer
$results = [];
if ($rs !== false) {
do {
$row = $rs->fetch_array(MYSQLI_ASSOC);
if ((bool) $row !== false) {
$results[] = $row;
}
} while ((bool) $row !== false);
}
return $results;
}
@ -412,6 +414,10 @@ final class DBMaintainer
return true;
}
if ($this->dbh === null) {
return false;
}
$rc = $this->dbh->query(
sprintf(
'CREATE DATABASE %s',
@ -503,7 +509,7 @@ final class DBMaintainer
return false;
}
if ($this->install() !== true) {
if ($this->install($check_only) !== true) {
return false;
}
@ -564,7 +570,7 @@ final class DBMaintainer
}
}
if ($this->applyDump($filename) !== true) {
if ($this->applyDump($filename, true) !== true) {
$err = 'Unable to apply MR update #';
$err .= $last_mr_curr.': ';
$this->lastError = $err.$this->lastError;
@ -630,6 +636,23 @@ final class DBMaintainer
}
/**
* Checks if target is ready to connect.
*
* @return boolean
*/
public function isReady()
{
if ($this->ready === true) {
return true;
}
$this->connect();
return $this->ready;
}
/**
* Checks if current target is connected, installed and updated.
*
@ -658,12 +681,19 @@ final class DBMaintainer
* This function keeps same functionality as install.php:parse_mysqli_dump.
*
* @param string $path Path where SQL dump file is stored.
* @param boolean $transactional Use transactions from file (true) (MRs).
*
* @return boolean Success or not.
*/
private function applyDump(string $path)
private function applyDump(string $path, bool $transactional=false)
{
if (file_exists($path) === true) {
if ($transactional === true) {
global $config;
// MR are loaded in transactions.
include_once $config['homedir'].'/include/db/mysql.php';
return db_run_sql_file($path);
} else {
$file_content = file($path);
$query = '';
foreach ($file_content as $sql_line) {
@ -683,6 +713,7 @@ final class DBMaintainer
}
}
}
}
return true;
}

View File

@ -603,6 +603,11 @@ select:-internal-list-box {
.flex-nowrap {
flex-wrap: nowrap;
}
.flex-evenly {
justify-content: space-evenly;
}
.flex-row-baseline {
display: flex;
flex-direction: row;

View File

@ -18,3 +18,7 @@ input[type="text"],
input[type="number"] {
width: 220px;
}
.fit > tbody > tr > td img {
width: 15px;
}