Skip to content

Commit c79679e

Browse files
authored
Update src/DB_Command.php
1 parent 5a4cb28 commit c79679e

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

‎src/DB_Command.php‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,22 @@ public function export( $args, $assoc_args ) {
737737

738738
$exclude_tables_data = Utils\get_flag_value( $assoc_args, 'exclude_tables_data' );
739739
if ( isset( $exclude_tables_data ) ) {
740-
$tables = explode( ',', trim( $assoc_args['exclude_tables_data'], ',' ) );
741740
unset( $assoc_args['exclude_tables_data'] );
742-
foreach ( $tables as $table ) {
743-
$command .= ' --ignore-table-data';
744-
$command .= ' %s';
745-
$command_esc_args[] = trim( DB_NAME . '.' . $table );
741+
if ( is_string( $exclude_tables_data ) && '' !== trim( $exclude_tables_data ) ) {
742+
if ( 'mariadb' !== Utils\get_db_type() ) {
743+
WP_CLI::error( 'The --exclude_tables_data option is only supported by MariaDB.' );
744+
}
745+
746+
$tables = explode( ',', trim( $exclude_tables_data, ',' ) );
747+
foreach ( $tables as $table ) {
748+
$table = trim( $table );
749+
if ( '' === $table ) {
750+
continue;
751+
}
752+
$command .= ' --ignore-table-data';
753+
$command .= ' %s';
754+
$command_esc_args[] = DB_NAME . '.' . $table;
755+
}
746756
}
747757
}
748758

0 commit comments

Comments
 (0)