Revize ed986471
Přidáno uživatelem Ondřej Fibich před téměř 6 roky(ů)
application/libraries/Settings.php | ||
---|---|---|
* @var Config_Model
|
||
*/
|
||
private static $config_model = NULL;
|
||
|
||
/**
|
||
* When turned ON no DB queries are performed. Useful for non-setup
|
||
* environment.
|
||
*
|
||
* @var bool
|
||
*/
|
||
private static $offline_mode = FALSE;
|
||
|
||
/**
|
||
* Variable for cache
|
||
... | ... | |
// not connected? connect!
|
||
if (!self::$config_model)
|
||
{
|
||
if (self::$offline_mode)
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
try
|
||
{
|
||
// create config model
|
||
... | ... | |
{
|
||
// init
|
||
self::init();
|
||
|
||
|
||
// if cache is enabled, return it from it
|
||
if ($cache && isset(self::$cache[$key]))
|
||
{
|
||
return self::$cache[$key];
|
||
}
|
||
|
||
$value = '';
|
||
|
||
// try if query return exception, for example config table doesn't exist
|
||
try
|
||
{
|
||
$value = self::$config_model->get_value_from_name($key);
|
||
if (!self::$offline_mode)
|
||
{
|
||
$value = self::$config_model->get_value_from_name($key);
|
||
}
|
||
}
|
||
catch (Kohana_Database_Exception $e)
|
||
{
|
||
$value = '';
|
||
}
|
||
|
||
// if we find not-null value, return it
|
||
... | ... | |
*/
|
||
public static function set($key, $value)
|
||
{
|
||
if (self::$offline_mode)
|
||
{
|
||
self::cache_value_set($key, $value);
|
||
return FALSE;
|
||
}
|
||
|
||
// init
|
||
self::init();
|
||
|
Také k dispozici: Unified diff
Refs #1101: Support for Debian Stretch (PHP 7.0 + Maria DB 15.1). Improved setup that no longer support database creation (in Maria DB it is hard to do so from non-root user due to security restrictions), database setup error cause was added, disabling Settings DB queries in non-setup environment. In order to fix DB init some FK indexes/constrains must have been renamed in 1.1.0 SQL script (Maria DB enforces uniqueness on FK names).