mirror of
https://github.com/friendica/friendica
synced 2025-04-30 00:24:24 +02:00
Rework App modes
- Replace App mode constants with capability-based flags - Add App->isInstallMode() - Add file config fallback in (P)Config abstraction - Removed logger disabling code
This commit is contained in:
parent
d487c399dd
commit
cd9b864045
12 changed files with 74 additions and 79 deletions
|
@ -30,7 +30,7 @@ class Config extends BaseObject
|
|||
public static function init()
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (self::getApp()->mode === \Friendica\App::MODE_INSTALL) {
|
||||
if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ class Config extends BaseObject
|
|||
public static function load($family = "config")
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (self::getApp()->mode === \Friendica\App::MODE_INSTALL) {
|
||||
if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ class Config extends BaseObject
|
|||
public static function get($family, $key, $default_value = null, $refresh = false)
|
||||
{
|
||||
// Database isn't ready or populated yet, fallback to file config
|
||||
if (self::getApp()->mode === \Friendica\App::MODE_INSTALL) {
|
||||
if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
|
||||
return self::getApp()->getConfigValue($family, $key, $default_value);
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ class Config extends BaseObject
|
|||
public static function set($family, $key, $value)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (self::getApp()->mode === \Friendica\App::MODE_INSTALL) {
|
||||
if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ class Config extends BaseObject
|
|||
public static function delete($family, $key)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (self::getApp()->mode === \Friendica\App::MODE_INSTALL) {
|
||||
if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ HELP;
|
|||
throw new CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if ($a->mode === \Friendica\App::MODE_INSTALL) {
|
||||
if (!($a->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
|
||||
$this->out('Database isn\'t ready or populated yet, showing file config only');
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ HELP;
|
|||
if (count($this->args) == 0) {
|
||||
Core\Config::load();
|
||||
|
||||
if (Core\Config::get('system', 'config_adapter') != 'preload' && $a->mode !== \Friendica\App::MODE_INSTALL) {
|
||||
if (Core\Config::get('system', 'config_adapter') != 'preload' && $a->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE) {
|
||||
$this->out('Warning: The JIT (Just In Time) Config adapter doesn\'t support loading the entire configuration, showing file config only');
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ HELP;
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if ($a->mode == \Friendica\App::MODE_INSTALL) {
|
||||
if ($a->isInstallMode()) {
|
||||
throw new \RuntimeException('Database isn\'t ready or populated yet');
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ HELP;
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if ($a->mode == \Friendica\App::MODE_INSTALL) {
|
||||
if ($a->isInstallMode()) {
|
||||
throw new \RuntimeException('Database isn\'t ready or populated yet');
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ HELP;
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if ($a->mode == \Friendica\App::MODE_INSTALL) {
|
||||
if ($a->isInstallMode()) {
|
||||
throw new \RuntimeException('Database isn\'t ready or populated yet');
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ HELP;
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
if ($a->mode == \Friendica\App::MODE_INSTALL) {
|
||||
if ($a->isInstallMode()) {
|
||||
throw new \RuntimeException('Database isn\'t ready or populated yet');
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class PConfig extends BaseObject
|
|||
public static function init($uid)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (self::getApp()->mode === \Friendica\App::MODE_INSTALL) {
|
||||
if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ class PConfig extends BaseObject
|
|||
public static function load($uid, $family)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (self::getApp()->mode === \Friendica\App::MODE_INSTALL) {
|
||||
if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class PConfig extends BaseObject
|
|||
public static function get($uid, $family, $key, $default_value = null, $refresh = false)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (self::getApp()->mode === \Friendica\App::MODE_INSTALL) {
|
||||
if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ class PConfig extends BaseObject
|
|||
public static function set($uid, $family, $key, $value)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (self::getApp()->mode === \Friendica\App::MODE_INSTALL) {
|
||||
if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ class PConfig extends BaseObject
|
|||
public static function delete($uid, $family, $key)
|
||||
{
|
||||
// Database isn't ready or populated yet
|
||||
if (self::getApp()->mode === \Friendica\App::MODE_INSTALL) {
|
||||
if (!(self::getApp()->mode & \Friendica\App::MODE_DBCONFIGAVAILABLE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,20 +85,6 @@ class System extends BaseObject
|
|||
return implode(', ', $callstack2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called from db initialisation when db is dead.
|
||||
*/
|
||||
static public function unavailable() {
|
||||
echo <<< EOT
|
||||
<html>
|
||||
<head><title>System Unavailable</title></head>
|
||||
<body>Apologies but this site is unavailable at the moment. Please try again later.</body>
|
||||
</html>
|
||||
EOT;
|
||||
|
||||
killme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic XML return
|
||||
* Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue