Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions ProcessMaker/Multitenancy/TenantBootstrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,26 @@ class TenantBootstrapper
'LOG_PATH',
'DB_USERNAME',
'DB_PASSWORD',
'DB_HOSTNAME',
'DB_PORT',
'LANDLORD_DB_DATABASE',
'REDIS_PREFIX',
'CACHE_SETTING_PREFIX',
'SCRIPT_MICROSERVICE_CALLBACK',
'CACHE_PREFIX',
];

public function bootstrap(Application $app)
{
try {
$this->bootstrapRun($app);
} catch (\Exception $e) {
file_put_contents(storage_path('logs/tenant_bootstrapper_error.log'), date('Y-m-d H:i:s') . ' ' . get_class($e) . ' in ' . $e->getFile() . ':' . $e->getLine() . ' ' . $e->getMessage() . PHP_EOL, FILE_APPEND);
throw $e;
}
}

public function bootstrapRun(Application $app)
{
if (!$this->env('MULTITENANCY')) {
return;
Expand Down Expand Up @@ -100,14 +113,14 @@ private function setTenantEnvironmentVariables($tenantData)
$this->set('LOG_PATH', $this->app->storagePath('logs/processmaker.log'));
}

private function getOriginalValue($key)
private function getOriginalValue($key, $default = '')
{
if (self::$landlordValues === []) {
self::$landlordValues = Dotenv::parse(file_get_contents(base_path('.env')));
}

if (!isset(self::$landlordValues[$key])) {
return '';
return $default;
}

return self::$landlordValues[$key];
Expand Down Expand Up @@ -146,11 +159,11 @@ private function decrypt($value)
private function getLandlordDbConfig(): array
{
return [
'host' => $this->env('DB_HOSTNAME', 'localhost'),
'port' => $this->env('DB_PORT', '3306'),
'database' => $this->env('LANDLORD_DB_DATABASE', 'landlord'),
'username' => $this->env('DB_USERNAME'),
'password' => $this->env('DB_PASSWORD'),
'host' => $this->getOriginalValue('DB_HOSTNAME', 'localhost'),
'port' => $this->getOriginalValue('DB_PORT', '3306'),
'database' => $this->getOriginalValue('LANDLORD_DB_DATABASE', 'landlord'),
'username' => $this->getOriginalValue('DB_USERNAME'),
'password' => $this->getOriginalValue('DB_PASSWORD'),
'charset' => 'utf8mb4',
];
}
Expand Down
Loading