-
diff --git a/resources/templates/server/privileges/login_information_fields.twig b/resources/templates/server/privileges/login_information_fields.twig
index f619dba081..9a2794a5e8 100644
--- a/resources/templates/server/privileges/login_information_fields.twig
+++ b/resources/templates/server/privileges/login_information_fields.twig
@@ -5,13 +5,13 @@
+ {{- predefined_username == 'userdefined' ? ' required' }}>
{{ t('An account already exists with the same username but possibly a different hostname.')|notice }}
diff --git a/src/Replication/ReplicationGui.php b/src/Replication/ReplicationGui.php
index 6683ee94c7..37c53dec64 100644
--- a/src/Replication/ReplicationGui.php
+++ b/src/Replication/ReplicationGui.php
@@ -379,8 +379,9 @@ class ReplicationGui
[$usernameLength, $hostnameLength] = $this->getUsernameHostnameLength();
$username = '';
+ $predefinedUsername = 'userdefined';
if ($postUsername === '') {
- $GLOBALS['pred_username'] = 'any';
+ $predefinedUsername = 'any';
} elseif ($postUsername !== null && $postUsername !== '0') {
$username = $GLOBALS['new_username'] ?? $postUsername;
}
@@ -415,7 +416,7 @@ class ReplicationGui
'has_username' => $postUsername !== null,
'username' => $username,
'hostname' => $hostname ?? '',
- 'predefined_username' => $GLOBALS['pred_username'] ?? '',
+ 'predefined_username' => $predefinedUsername,
'predefined_hostname' => $GLOBALS['pred_hostname'] ?? '',
'this_host' => $thisHost ?? null,
]);
diff --git a/src/Server/Privileges.php b/src/Server/Privileges.php
index de7e2a565e..38ce68ef8d 100644
--- a/src/Server/Privileges.php
+++ b/src/Server/Privileges.php
@@ -595,15 +595,12 @@ class Privileges
string|null $user = null,
string|null $host = null,
): string {
- $GLOBALS['pred_username'] ??= null;
$GLOBALS['pred_hostname'] ??= null;
$GLOBALS['new_username'] ??= null;
[$usernameLength, $hostnameLength] = $this->getUsernameAndHostnameLength();
- if ($this->username !== null && $this->username === '') {
- $GLOBALS['pred_username'] = 'any';
- }
+ $predefinedUsername = $this->username === '' ? 'any' : 'userdefined';
$currentUser = (string) $this->dbi->fetchValue('SELECT USER();');
$thisHost = null;
@@ -645,7 +642,7 @@ class Privileges
}
return $this->template->render('server/privileges/login_information_fields', [
- 'pred_username' => $GLOBALS['pred_username'] ?? null,
+ 'predefined_username' => $predefinedUsername,
'pred_hostname' => $GLOBALS['pred_hostname'] ?? null,
'username_length' => $usernameLength,
'hostname_length' => $hostnameLength,