fix: provide web friendly session driver name (#3690)

This commit is contained in:
Ian Morland 2022-11-22 17:02:44 +00:00 committed by GitHub
parent e5d2b8cad9
commit 67dd2c21b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -113,7 +113,7 @@ class AdminPayload
}
$document->payload['queueDriver'] = $this->appInfo->identifyQueueDriver();
$document->payload['sessionDriver'] = $this->appInfo->identifySessionDriver();
$document->payload['sessionDriver'] = $this->appInfo->identifySessionDriver(true);
/**
* Used in the admin user list. Implemented as this as it matches the API in flarum/statistics.

View File

@ -157,7 +157,7 @@ class ApplicationInfoProvider
* 2. If the configured session driver is invalid, fallback to the default one and mention it.
* 3. If the actual used driver (i.e `session.handler`) is different from the current one (configured or default), mention it.
*/
public function identifySessionDriver(): string
public function identifySessionDriver(bool $forWeb = false): string
{
/*
* Get the configured driver and fallback to the default one.
@ -190,11 +190,11 @@ class ApplicationInfoProvider
$handlerName = str_replace('sessionhandler', '', $handlerName);
if ($driver !== $handlerName) {
return "$handlerName <comment>(Code override. Configured to <options=bold,underscore>$configuredDriver</>)</comment>";
return $forWeb ? $handlerName : "$handlerName <comment>(Code override. Configured to <options=bold,underscore>$configuredDriver</>)</comment>";
}
if ($driver !== $configuredDriver) {
return "$driver <comment>(Fallback default driver. Configured to invalid driver <options=bold,underscore>$configuredDriver</>)</comment>";
return $forWeb ? $driver : "$driver <comment>(Fallback default driver. Configured to invalid driver <options=bold,underscore>$configuredDriver</>)</comment>";
}
return $driver;