Skip to content

Commit 6ae6c70

Browse files
authored
Merge pull request #8508 from ProcessMaker/bugfix/FOUR-26131
Clean up LDAP errors and fix provider order
2 parents 8d90004 + 0b65b04 commit 6ae6c70

File tree

7 files changed

+34
-18
lines changed

7 files changed

+34
-18
lines changed

ProcessMaker/Application.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace ProcessMaker;
44

55
use Igaster\LaravelTheme\Facades\Theme;
6+
use Illuminate\Filesystem\Filesystem;
67
use Illuminate\Foundation\Application as IlluminateApplication;
8+
use Illuminate\Foundation\PackageManifest;
79
use Illuminate\Support\Facades\Auth;
810

911
/**
@@ -78,13 +80,14 @@ public function path($path = '')
7880
return $this->basePath . DIRECTORY_SEPARATOR . 'ProcessMaker' . ($path ? DIRECTORY_SEPARATOR . $path : $path);
7981
}
8082

81-
public function setStoragePath($path)
83+
public function registerConfiguredProviders()
8284
{
83-
$this->storagePath = $path;
84-
}
85+
// Must be rebound before registerConfiguredProviders() runs but after bootstrapping is done
86+
// so we can access storage and cache facades.
87+
$this->singleton(PackageManifest::class, fn () => new LicensedPackageManifest(
88+
new Filesystem, $this->basePath(), $this->getCachedPackagesPath()
89+
));
8590

86-
public function getStoragePath()
87-
{
88-
return $this->storagePath;
91+
parent::registerConfiguredProviders();
8992
}
9093
}

ProcessMaker/Console/Commands/TenantsList.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public function handle()
4343
$formattedTenants = $tenants->map(function ($tenant) {
4444
$config = $tenant->config;
4545

46+
if (isset($config['app.key'])) {
47+
$config['app.key'] = substr($config['app.key'], 0, 30);
48+
}
49+
4650
// Json encode, pretty print without slashes
4751
$config = json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
4852

ProcessMaker/LicensedPackageManifest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ class LicensedPackageManifest extends PackageManifest
2020

2121
const LAST_PACKAGE_DISCOVERY = 0;
2222

23+
/**
24+
* Consider this the beginning of licenesing refactor for multitenancy.
25+
*
26+
* For now, this will just move the Spatie MultitenancyServiceProvider to the beginning of the service providers.
27+
*/
28+
protected function getManifest()
29+
{
30+
$manifest = parent::getManifest();
31+
$multitenancyKey = 'spatie/laravel-multitenancy';
32+
33+
// Make sure the MultitenancyServiceProvider is at the beginning of the manifest
34+
return [$multitenancyKey => $manifest[$multitenancyKey]] + $manifest;
35+
}
36+
2337
protected function packagesToIgnore()
2438
{
2539
$packagesToIgnore = $this->loadPackagesToIgnore()->all();

ProcessMaker/Multitenancy/SwitchTenant.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function makeCurrent(IsTenant $tenant): void
3939
$tenantStoragePath = base_path('storage/tenant_' . $tenant->id);
4040

4141
$app = app();
42-
$app->setStoragePath($tenantStoragePath);
42+
$app->useStoragePath($tenantStoragePath);
4343

4444
// Create the tenant storage directory if it doesn't exist
4545
// TODO: Move these to somewhere else - should not be run on every request

ProcessMaker/Providers/AuthServiceProvider.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ public function boot()
8585

8686
public function defineGates()
8787
{
88+
// No need to run this in console and it generates
89+
// errors in multitenancy mode
90+
if (!app()->environment('testing') && app()->runningInConsole()) {
91+
return;
92+
}
93+
8894
try {
8995
// Cache the permissions for a day to improve performance
9096
$permissions = Cache::remember('permissions', 86400, function () {

ProcessMaker/Providers/LicenseServiceProvider.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,4 @@ public function boot(): void
3737
LicensedPackageManifest::discoverPackagesOnce();
3838
}
3939
}
40-
41-
public function register(): void
42-
{
43-
$this->app->singleton(PackageManifest::class, fn () => new LicensedPackageManifest(
44-
new Filesystem, $this->app->basePath(), $this->app->getCachedPackagesPath()
45-
));
46-
}
4740
}

ProcessMaker/Providers/ProcessMakerServiceProvider.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,6 @@ public function register(): void
259259
// Miscellaneous vendor customization
260260
static::configureVendors();
261261

262-
$this->app->singleton(PackageManifest::class, fn () => new LicensedPackageManifest(
263-
new Filesystem, $this->app->basePath(), $this->app->getCachedPackagesPath()
264-
));
265-
266262
$this->app->extend(MigrateCommand::class, function () {
267263
return new ExtendedMigrateCommand(
268264
app('migrator'),

0 commit comments

Comments
 (0)