Merge #18225 - Make database and web server info separately configurable on $cfg['ShowServerInfo']

Pull-request: #18225

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2023-03-10 16:20:37 +01:00
commit e8b1437fff
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889
5 changed files with 35 additions and 8 deletions

View File

@ -2427,13 +2427,23 @@ Main panel
.. config:option:: $cfg['ShowServerInfo']
:type: boolean
:type: boolean|string
:default: true
Defines whether to display detailed server information on main page.
Possible values are:
* ``true`` to show all server information
* ``false`` to hide server information
* ``'database-server'`` to show only database server information
* ``'web-server'`` to show only web server information
You can additionally hide more information by using
:config:option:`$cfg['Servers'][$i]['verbose']`.
.. versionchanged:: 6.0.0
Added ``'database-server'`` and ``'web-server'`` options.
.. config:option:: $cfg['ShowPhpInfo']
:type: boolean

View File

@ -1049,15 +1049,17 @@ final class Settings
public bool $ShowPhpInfo;
/**
* show MySQL server and web server information
* show MySQL server and/or web server information (true|false|'database-server'|'web-server')
*
* ```php
* $cfg['ShowServerInfo'] = true;
* ```
*
* @link https://docs.phpmyadmin.net/en/latest/config.html#cfg_ShowServerInfo
*
* @psalm-var bool|'database-server'|'web-server'
*/
public bool $ShowServerInfo;
public bool|string $ShowServerInfo;
/**
* show change password link
@ -3826,13 +3828,25 @@ final class Settings
return (bool) $settings['ShowPhpInfo'];
}
/** @param array<int|string, mixed> $settings */
private function setShowServerInfo(array $settings): bool
/**
* @param array<int|string, mixed> $settings
*
* @psalm-return bool|'database-server'|'web-server'
*/
private function setShowServerInfo(array $settings): bool|string
{
if (! isset($settings['ShowServerInfo'])) {
return true;
}
if ($settings['ShowServerInfo'] === 'database-server') {
return 'database-server';
}
if ($settings['ShowServerInfo'] === 'web-server') {
return 'web-server';
}
return (bool) $settings['ShowServerInfo'];
}

View File

@ -139,8 +139,9 @@ class HomeController extends AbstractController
$availableLanguages = $languageManager->sortedLanguages();
}
$showServerInfo = $GLOBALS['cfg']['ShowServerInfo'];
$databaseServer = [];
if ($GLOBALS['server'] > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
if ($GLOBALS['server'] > 0 && ($showServerInfo === true || $showServerInfo === 'database-server')) {
$hostInfo = '';
if (! empty($GLOBALS['cfg']['Server']['verbose'])) {
$hostInfo .= $GLOBALS['cfg']['Server']['verbose'] . ' (';
@ -164,7 +165,7 @@ class HomeController extends AbstractController
}
$webServer = [];
if ($GLOBALS['cfg']['ShowServerInfo']) {
if ($showServerInfo === true || $showServerInfo === 'web-server') {
$webServer['software'] = $_SERVER['SERVER_SOFTWARE'] ?? null;
if ($GLOBALS['server'] > 0) {

View File

@ -203,7 +203,7 @@
ShowFunctionFields: bool,
ShowHint: bool,
ShowPropertyComments: bool,
ShowServerInfo: bool,
ShowServerInfo: bool|string,
ShowSQL: bool,
ShowStats: bool,
TextareaAutoSelect: bool,

View File

@ -746,6 +746,7 @@ class SettingsTest extends TestCase
['NavigationTreeDefaultTabTable', 'insert', 'insert'],
['NavigationTreeDefaultTabTable2', 'insert', 'insert'],
['TableNavigationLinksMode', 'both', 'both'],
['ShowServerInfo', 'database-server', 'database-server'],
['Order', 'DESC', 'DESC'],
['GridEditing', 'disabled', 'disabled'],
['RelationalDisplay', 'K', 'K'],
@ -778,6 +779,7 @@ class SettingsTest extends TestCase
['NavigationTreeDefaultTabTable', 'structure', 'structure'],
['NavigationTreeDefaultTabTable2', 'structure', 'structure'],
['TableNavigationLinksMode', 'icons', 'icons'],
['ShowServerInfo', 'web-server', 'web-server'],
['Order', 'SMART', 'SMART'],
['GridEditing', 'double-click', 'double-click'],
['ProtectBinary', 'blob', 'blob'],