Skip to content

Commit 7f2d7d9

Browse files
Copilotswissspidy
andcommitted
Simplify code by calling parent::run_query directly and remove test-output.txt
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 891f713 commit 7f2d7d9

2 files changed

Lines changed: 6 additions & 61 deletions

File tree

src/DB_Users_Command.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,37 +76,24 @@ public function create( $args, $assoc_args ) {
7676
}
7777
$create_query .= ';';
7878

79-
$this->run_user_query( $create_query, $assoc_args );
79+
parent::run_query( $create_query, $assoc_args );
8080

8181
// Grant privileges if requested
8282
if ( $grant_privileges ) {
8383
$database = DB_NAME;
8484
$database_escaped = $this->esc_sql_ident( $database );
8585
$grant_query = "GRANT ALL PRIVILEGES ON {$database_escaped}.* TO {$user_identifier};";
86-
$this->run_user_query( $grant_query, $assoc_args );
86+
parent::run_query( $grant_query, $assoc_args );
8787

8888
// Flush privileges
89-
$this->run_user_query( 'FLUSH PRIVILEGES;', $assoc_args );
89+
parent::run_query( 'FLUSH PRIVILEGES;', $assoc_args );
9090

9191
WP_CLI::success( "Database user '{$username}'@'{$host}' created with privileges on database '{$database}'." );
9292
} else {
9393
WP_CLI::success( "Database user '{$username}'@'{$host}' created." );
9494
}
9595
}
9696

97-
/**
98-
* Run a single query via the 'mysql' binary.
99-
*
100-
* This method adds SQL mode compatibility and delegates to the parent class.
101-
*
102-
* @param string $query Query to execute.
103-
* @param array $assoc_args Optional. Associative array of arguments.
104-
*/
105-
private function run_user_query( $query, $assoc_args = [] ) {
106-
// Use parent class's run_query method which handles SQL mode compatibility.
107-
parent::run_query( $query, $assoc_args );
108-
}
109-
11097
/**
11198
* Escapes a string for use in a SQL query.
11299
*
@@ -123,6 +110,9 @@ private function esc_sql_string( $value ) {
123110
/**
124111
* Escapes (backticks) MySQL identifiers (aka schema object names).
125112
*
113+
* Note: This duplicates functionality from parent DB_Command::esc_sql_ident()
114+
* which is private static and cannot be accessed from child classes.
115+
*
126116
* @param string $ident A single identifier.
127117
* @return string An escaped string.
128118
*/

test-output.txt

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)