mirror of
https://github.com/humhub/humhub.git
synced 2025-04-25 09:43:59 +02:00
Refactor applicationState mechanism - fixes/revert
This commit is contained in:
parent
5cde648369
commit
dba964da3f
@ -12,7 +12,7 @@ $dotenv = Dotenv\Dotenv::createImmutable(__DIR__, '.env');
|
||||
$dotenv->safeLoad();
|
||||
|
||||
$dynamicConfig = (is_readable(__DIR__ . '/protected/config/dynamic.php')) ? require(__DIR__ . '/protected/config/dynamic.php') : [];
|
||||
$debug = !!($_ENV['HUMHUB_DEBUG'] ?? false) || !($dynamicConfig['params']['installed'] ?? false);
|
||||
$debug = filter_var($_ENV['HUMHUB_DEBUG'] ?? false, FILTER_VALIDATE_BOOLEAN) || !filter_var($dynamicConfig['params']['installed'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', $debug);
|
||||
defined('YII_ENV') or define('YII_ENV', $debug ? 'dev' : 'prod');
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace humhub\components;
|
||||
|
||||
use humhub\helpers\DatabaseHelper;
|
||||
use humhub\libs\DatabaseCredConfig;
|
||||
use humhub\libs\DynamicConfig;
|
||||
use Yii;
|
||||
use yii\base\BaseObject;
|
||||
use yii\base\StaticInstanceInterface;
|
||||
@ -35,7 +35,7 @@ class InstallationState extends BaseObject implements StaticInstanceInterface
|
||||
|
||||
public function init()
|
||||
{
|
||||
if (!YII_ENV_TEST && !DatabaseCredConfig::exist()) {
|
||||
if (!YII_ENV_TEST && !DynamicConfig::exist()) {
|
||||
$this->state = self::STATE_NOT_INSTALLED;
|
||||
} else {
|
||||
$this->state = Yii::$app->settings->get(self::class, self::STATE_NOT_INSTALLED);
|
||||
|
@ -20,7 +20,7 @@ use yii\helpers\ArrayHelper;
|
||||
*
|
||||
* @author luke
|
||||
*/
|
||||
class DatabaseCredConfig extends BaseObject
|
||||
class DynamicConfig extends BaseObject
|
||||
{
|
||||
/**
|
||||
* Returns the dynamic configuration
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use humhub\components\InstallationState;
|
||||
use humhub\libs\DatabaseCredConfig;
|
||||
use humhub\libs\DynamicConfig;
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
@ -15,7 +15,7 @@ class m241211_193138_reduce_dynamic_config extends Migration
|
||||
public function safeUp()
|
||||
{
|
||||
if (Yii::$app->installationState->hasState(InstallationState::STATE_INSTALLED)) {
|
||||
DatabaseCredConfig::load();
|
||||
DynamicConfig::load();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
namespace humhub\modules\installer\commands;
|
||||
|
||||
use humhub\helpers\DatabaseHelper;
|
||||
use humhub\libs\DatabaseCredConfig;
|
||||
use humhub\libs\DynamicConfig;
|
||||
use humhub\libs\UUID;
|
||||
use humhub\modules\installer\libs\InitialData;
|
||||
use humhub\modules\user\models\Group;
|
||||
@ -63,11 +63,11 @@ class InstallController extends Controller
|
||||
$temporaryConnection = Yii::createObject($dbConfig);
|
||||
$temporaryConnection->open();
|
||||
|
||||
$config = DatabaseCredConfig::load();
|
||||
$config = DynamicConfig::load();
|
||||
|
||||
$config['components']['db'] = $dbConfig;
|
||||
|
||||
DatabaseCredConfig::save($config);
|
||||
DynamicConfig::save($config);
|
||||
|
||||
return ExitCode::OK;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace humhub\modules\installer\controllers;
|
||||
|
||||
use humhub\components\access\ControllerAccess;
|
||||
use humhub\components\Controller;
|
||||
use humhub\libs\DatabaseCredConfig;
|
||||
use humhub\libs\DynamicConfig;
|
||||
|
||||
/**
|
||||
* Index Controller shows a simple welcome page.
|
||||
@ -39,7 +39,7 @@ class IndexController extends Controller
|
||||
*/
|
||||
public function actionGo()
|
||||
{
|
||||
if (DatabaseCredConfig::exist() && $this->module->checkDBConnection()) {
|
||||
if (DynamicConfig::exist() && $this->module->checkDBConnection()) {
|
||||
return $this->redirect(['setup/finalize']);
|
||||
} else {
|
||||
return $this->redirect(['setup/prerequisites']);
|
||||
|
@ -11,7 +11,7 @@ namespace humhub\modules\installer\controllers;
|
||||
use Exception;
|
||||
use humhub\components\access\ControllerAccess;
|
||||
use humhub\components\Controller;
|
||||
use humhub\libs\DatabaseCredConfig;
|
||||
use humhub\libs\DynamicConfig;
|
||||
use humhub\modules\admin\widgets\PrerequisitesList;
|
||||
use humhub\modules\installer\forms\DatabaseForm;
|
||||
use humhub\modules\installer\Module;
|
||||
@ -66,7 +66,7 @@ class SetupController extends Controller
|
||||
{
|
||||
$errorMessage = "";
|
||||
|
||||
$config = DatabaseCredConfig::load();
|
||||
$config = DynamicConfig::load();
|
||||
|
||||
$model = new DatabaseForm();
|
||||
if (isset($config['params']['installer']['db']['installer_hostname'])) {
|
||||
@ -151,7 +151,7 @@ class SetupController extends Controller
|
||||
$config['components']['db'] = $dbConfig;
|
||||
unset($config['params']);
|
||||
|
||||
DatabaseCredConfig::save($config);
|
||||
DynamicConfig::save($config);
|
||||
|
||||
return $this->redirect(['migrate']);
|
||||
} catch (Exception $e) {
|
||||
@ -168,7 +168,7 @@ class SetupController extends Controller
|
||||
}
|
||||
|
||||
if (!empty($config['params'])) {
|
||||
DatabaseCredConfig::save($config);
|
||||
DynamicConfig::save($config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
namespace humhub\modules\installer\libs;
|
||||
|
||||
use humhub\libs\DatabaseCredConfig;
|
||||
use humhub\libs\DynamicConfig;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
@ -33,7 +33,7 @@ class EnvironmentChecker
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$dynamicConfigFile = DatabaseCredConfig::getConfigFilePath();
|
||||
$dynamicConfigFile = DynamicConfig::getConfigFilePath();
|
||||
if (file_exists($dynamicConfigFile) && !is_writable($dynamicConfigFile)) {
|
||||
print "Error: The dynamic configuration (config/dynamic.php) is not writable by the PHP process.";
|
||||
exit(1);
|
||||
|
@ -13,7 +13,7 @@ $dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../', '.env');
|
||||
$dotenv->safeLoad();
|
||||
|
||||
$dynamicConfig = (is_readable(__DIR__ . '/config/dynamic.php')) ? require(__DIR__ . '/config/dynamic.php') : [];
|
||||
$debug = !!($_ENV['HUMHUB_DEBUG'] ?? false) || !($dynamicConfig['params']['installed'] ?? false);
|
||||
$debug = filter_var($_ENV['HUMHUB_DEBUG'] ?? false, FILTER_VALIDATE_BOOLEAN) || !filter_var($dynamicConfig['params']['installed'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', $debug);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user