diff --git a/psalm-baseline.xml b/psalm-baseline.xml index cbd4208503..af5884ec7c 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -8667,7 +8667,6 @@ - @@ -8786,7 +8785,6 @@ - @@ -8840,7 +8838,6 @@ - diff --git a/resources/templates/server/privileges/login_information_fields.twig b/resources/templates/server/privileges/login_information_fields.twig index 9a2794a5e8..22451e94b1 100644 --- a/resources/templates/server/privileges/login_information_fields.twig +++ b/resources/templates/server/privileges/login_information_fields.twig @@ -25,17 +25,17 @@ + {{- t('Host name') }}"{{ predefined_hostname == 'userdefined' ? ' required' }}> {{ show_hint(t('When Host table is used, this field is ignored and values stored in Host table are used instead.')) }} diff --git a/src/Replication/ReplicationGui.php b/src/Replication/ReplicationGui.php index 37c53dec64..098b0646cf 100644 --- a/src/Replication/ReplicationGui.php +++ b/src/Replication/ReplicationGui.php @@ -401,9 +401,9 @@ class ReplicationGui } } - // when we start editing a user, $GLOBALS['pred_hostname'] is not defined - if (! isset($GLOBALS['pred_hostname']) && $hostname !== null) { - $GLOBALS['pred_hostname'] = match (mb_strtolower($hostname)) { + $predefinedHostname = 'any'; + if ($hostname !== null) { + $predefinedHostname = match (mb_strtolower($hostname)) { 'localhost', '127.0.0.1' => 'localhost', '%' => 'any', default => 'userdefined', @@ -417,7 +417,7 @@ class ReplicationGui 'username' => $username, 'hostname' => $hostname ?? '', 'predefined_username' => $predefinedUsername, - 'predefined_hostname' => $GLOBALS['pred_hostname'] ?? '', + 'predefined_hostname' => $predefinedHostname, 'this_host' => $thisHost ?? null, ]); } diff --git a/src/Server/Privileges.php b/src/Server/Privileges.php index 38ce68ef8d..95c954889b 100644 --- a/src/Server/Privileges.php +++ b/src/Server/Privileges.php @@ -595,7 +595,6 @@ class Privileges string|null $user = null, string|null $host = null, ): string { - $GLOBALS['pred_hostname'] ??= null; $GLOBALS['new_username'] ??= null; [$usernameLength, $hostnameLength] = $this->getUsernameAndHostnameLength(); @@ -615,8 +614,9 @@ class Privileges ); } - if (! isset($GLOBALS['pred_hostname']) && $this->hostname !== null) { - $GLOBALS['pred_hostname'] = match (mb_strtolower($this->hostname)) { + $predefinedHostname = 'any'; + if ($this->hostname !== null) { + $predefinedHostname = match (mb_strtolower($this->hostname)) { 'localhost', '127.0.0.1' => 'localhost', '%' => 'any', default => 'userdefined', @@ -643,7 +643,7 @@ class Privileges return $this->template->render('server/privileges/login_information_fields', [ 'predefined_username' => $predefinedUsername, - 'pred_hostname' => $GLOBALS['pred_hostname'] ?? null, + 'predefined_hostname' => $predefinedHostname, 'username_length' => $usernameLength, 'hostname_length' => $hostnameLength, 'username' => $this->username,