Bug fix for translation class, DB IO connection error set fix

- The translation file reader did an isset on a set variable insetad of
checking if the variable is zero and so never started the translation
system
- The DB IO connection not set was wrongly set. If the connection failed
it is not TRUE and else FALSE. There is a new internal method
getConnectionStatus to query this status it returns TRUE/FALSE depending
if the connection failed

- Update the l10n test page with proper translation tests
  - init OK
  - show current lang/file
  - translation test
  - switch language test
This commit is contained in:
Clemens Schwaighofer
2019-09-19 15:26:56 +09:00
parent 98c87a755a
commit 4508692330
13 changed files with 57 additions and 20 deletions

View File

@@ -122,7 +122,7 @@ class Login extends \CoreLibs\DB\IO
// create db connection and init base class
parent::__construct($db_config, $set_control_flag);
if ($this->db_init_error === false) {
if ($this->db_init_error === true) {
echo 'Could not connect to DB<br>';
// if I can't connect to the DB to auth exit hard. No access allowed
exit;

View File

@@ -376,18 +376,15 @@ class IO extends \CoreLibs\Basic
// abort error
$this->error_id = 10;
$this->__dbError();
$this->db_init_error = false;
$this->db_init_error = true;
}
// connect to DB
if (!$this->__connectToDB()) {
$this->error_id = 16;
$this->__dbError();
$this->db_init_error = false;
$this->db_init_error = true;
}
// so we can check that we have a successful DB connection created
$this->db_init_error = true;
}
/**
@@ -897,6 +894,17 @@ class IO extends \CoreLibs\Basic
}
}
/**
* returns the db init error
* if failed to connect it is set to true
* else false
* @return bool connection failure status
*/
public function getConnectionStatus(): bool
{
return $this->db_init_error;
}
/**
* sets new db schema
* @param string $db_schema schema name, if not given tries internal default db schema

View File

@@ -106,7 +106,7 @@ class GetTextReader
public function __construct($Reader, $enable_cache = true)
{
// If there isn't a StreamReader, turn on short circuit mode.
if (!$Reader || isset($Reader->error)) {
if (!$Reader || $Reader->error) {
$this->short_circuit = true;
return;
}