Skip to content

Commit 381a520

Browse files
swissspidyCopilot
andauthored
Update src/DB_Users_Command.php
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent e70699d commit 381a520

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

‎src/DB_Users_Command.php‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,10 @@ public function create( $args, $assoc_args ) {
6767
$password = Utils\get_flag_value( $assoc_args, 'password', '' );
6868
$grant_privileges = Utils\get_flag_value( $assoc_args, 'grant-privileges', false );
6969

70-
// Escape identifiers for SQL
71-
// @phpstan-ignore cast.string (PHPStan doesn't infer conditional return type from parent method)
72-
$username_escaped = (string) self::esc_sql_ident( $username );
73-
// @phpstan-ignore cast.string (PHPStan doesn't infer conditional return type from parent method)
74-
$host_escaped = (string) self::esc_sql_ident( $host );
75-
$user_identifier = $username_escaped . '@' . $host_escaped;
70+
// MySQL account names in CREATE USER / GRANT ... TO use string literals, not identifiers.
71+
$username_escaped = $this->esc_sql_string( $username );
72+
$host_escaped = $this->esc_sql_string( $host );
73+
$user_identifier = $username_escaped . '@' . $host_escaped;
7674

7775
// Create user
7876
$create_query = "CREATE USER {$user_identifier}";

0 commit comments

Comments
 (0)