Skip to content

Commit e714ca2

Browse files
authored
Merge pull request #8654 from ProcessMaker/bugfix/FOUR-28402
FOUR-28402 Fix email settings in multitenancy
2 parents f335490 + e257146 commit e714ca2

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

ProcessMaker/Jobs/RefreshArtisanCaches.php

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,7 @@ class RefreshArtisanCaches implements ShouldQueue
2323
*/
2424
public function handle()
2525
{
26-
// Skip in testing environment because this reconnects the database
27-
// meaning we loose transactions, and sets the console output verbosity
28-
// to quiet so we loose expectsOutput assertions.
29-
if (app()->environment('testing')) {
30-
return;
31-
}
32-
33-
$options = [
34-
'--no-interaction' => true,
35-
'--quiet' => true,
36-
];
37-
38-
if (app()->configurationIsCached()) {
39-
// Run in a separate process to avoid the tenant being set.
40-
// We do not use a tenant-specific config cache file.
41-
Process::path(base_path())
42-
->env(['TENANT' => false, 'APP_URL' => false])
43-
->run(Application::formatCommandString('config:cache'))->throw();
44-
} else {
45-
Artisan::call('queue:restart', $options);
46-
47-
// We call this manually here since this job is dispatched
48-
// automatically when the config *is* cached
49-
RestartMessageConsumers::dispatchSync();
50-
}
26+
// Do not rebuild the cache and restart the queue any more.
27+
// This is no longer needed.
5128
}
5229
}

ProcessMaker/Providers/ProcessMakerServiceProvider.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Illuminate\Support\Arr;
1717
use Illuminate\Support\Env;
1818
use Illuminate\Support\Facades;
19+
use Illuminate\Support\Facades\Artisan;
1920
use Illuminate\Support\Facades\Context;
2021
use Illuminate\Support\Facades\DB;
2122
use Illuminate\Support\Facades\Log;
@@ -99,6 +100,9 @@ public function boot(): void
99100
parent::boot();
100101

101102
Route::pushMiddlewareToGroup('api', HandleEtag::class);
103+
104+
$this->checkConfigCache();
105+
102106
// Hook after service providers boot
103107
self::$bootTime = (microtime(true) - self::$bootStart) * 1000; // Convert to milliseconds
104108
}
@@ -577,4 +581,22 @@ private static function actuallyRunningInConsole(): bool
577581
{
578582
return PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg';
579583
}
584+
585+
/**
586+
* Ensure that config:cache is not run for tenant instances.
587+
*/
588+
private function checkConfigCache(): void
589+
{
590+
// Only if app is running in console
591+
if (!app()->runningInConsole()) {
592+
return;
593+
}
594+
595+
// Safety check to prevent config:cache from being run for tenant instances.
596+
if (config('app.multitenancy') && app('currentTenant')) {
597+
Artisan::command('config:cache', function () {
598+
throw new \Exception('Cannot cache config for tenant instance. Must be run from landlord instance.');
599+
});
600+
}
601+
}
580602
}

0 commit comments

Comments
 (0)