Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"require-dev": {
"justinrainbow/json-schema": "^6.3",
"roave/security-advisories": "dev-latest",
"squizlabs/php_codesniffer": "^3.13",
"wp-cli/db-command": "^2",
"wp-cli/entity-command": "^2",
"wp-cli/extension-command": "^2",
Expand Down
7 changes: 4 additions & 3 deletions php/commands/src/CLI_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use WP_CLI\Formatter;
use WP_CLI\Process;
use WP_CLI\Utils;
use function WP_CLI\Utils\esc_cmd;

/**
* Reviews current WP-CLI info, checks for updates, or views defined aliases.
Expand Down Expand Up @@ -377,9 +378,9 @@ static function ( $update ) {
$this->validate_hashes( $temp, $sha512_url, $md5_url );

$allow_root = WP_CLI::get_runner()->config['allow-root'] ? '--allow-root' : '';
$php_binary = Utils\get_php_binary();
$process = Process::create( "{$php_binary} $temp --info {$allow_root}" );
$result = $process->run();

$process = Process::create( esc_cmd( '%s %s --info %s', Utils\get_php_binary(), $temp, $allow_root ) );
$result = $process->run();
if ( 0 !== $result->return_code || false === stripos( $result->stdout, 'WP-CLI version' ) ) {
$multi_line = explode( PHP_EOL, $result->stderr );
WP_CLI::error_multi_line( $multi_line );
Expand Down
8 changes: 4 additions & 4 deletions php/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,7 @@ function get_db_type() {
$binary = get_mysql_binary_path();

if ( '' !== $binary ) {
$result = Process::create( "$binary --version", null, null )->run();
$result = Process::create( esc_cmd( '%s --version', $binary ), null, null )->run();

if ( 0 === $result->return_code ) {
$db_type = ( false !== strpos( $result->stdout, 'MariaDB' ) ) ? 'mariadb' : 'mysql';
Expand Down Expand Up @@ -1986,7 +1986,7 @@ function get_mysql_binary_path() {
if ( 0 === $mysql->return_code ) {
if ( '' !== $mysql_binary ) {
$path = $mysql_binary;
$result = Process::create( "$mysql_binary --version", null, null )->run();
$result = Process::create( esc_cmd( '%s --version', $mysql_binary ), null, null )->run();

// It's actually MariaDB disguised as MySQL.
if ( 0 === $result->return_code && false !== strpos( $result->stdout, 'MariaDB' ) && 0 === $mariadb->return_code ) {
Expand Down Expand Up @@ -2020,7 +2020,7 @@ function get_mysql_version() {
$db_type = get_db_type();

if ( 'sqlite' !== $db_type ) {
$result = Process::create( "/usr/bin/env $db_type --version", null, null )->run();
$result = Process::create( esc_cmd( '/usr/bin/env %s --version', $db_type ), null, null )->run();

if ( 0 === $result->return_code ) {
$version = trim( $result->stdout );
Expand Down Expand Up @@ -2066,7 +2066,7 @@ function get_sql_modes() {
if ( '' === $binary ) {
$sql_modes = [];
} else {
$result = Process::create( "$binary --no-auto-rehash --batch --skip-column-names --execute=\"SELECT @@SESSION.sql_mode\"", null, null )->run();
$result = Process::create( esc_cmd( '%s --no-auto-rehash --batch --skip-column-names --execute="SELECT @@SESSION.sql_mode"', $binary ), null, null )->run();

if ( 0 !== $result->return_code ) {
$sql_modes = [];
Expand Down