From: mattes Date: Fri, 16 Aug 2013 17:20:01 +0000 (+0200) Subject: fixed bug, when having a port number in host X-Git-Tag: v0.12.0~71^2~1 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=7bd05bacaf1d92172fe8f1f9c5a97b3b06119da2;p=wvm%2Fwvm.git fixed bug, when having a port number in host --- diff --git a/php/commands/db.php b/php/commands/db.php index 66ed93d5..fc04951e 100644 --- a/php/commands/db.php +++ b/php/commands/db.php @@ -119,9 +119,17 @@ class DB_Command extends WP_CLI_Command { function export( $args, $assoc_args ) { $result_file = $this->get_file_name( $args ); - self::run( 'mysqldump', Utils\esc_cmd( - '%s --user=%s --host=%s --result-file %s', - DB_NAME, DB_USER, DB_HOST, $result_file ) ); + if( strpos( DB_HOST, ':' ) !== false ) { + // extract port from host + $DB_HOST = preg_split("/:/", DB_HOST); + self::run( 'mysqldump', Utils\esc_cmd( + '%s --user=%s --host=%s --port=%s --result-file %s', + DB_NAME, DB_USER, $DB_HOST[0], $DB_HOST[1], $result_file ) ); + } else { + self::run( 'mysqldump', Utils\esc_cmd( + '%s --user=%s --host=%s --result-file %s', + DB_NAME, DB_USER, DB_HOST, $result_file ) ); + } WP_CLI::success( sprintf( 'Exported to %s', $result_file ) ); }