Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Linter fixes
  • Loading branch information
jeroenpf committed Jul 24, 2024
commit d33bb6651a4817259a141ef0bbde7766b7a5286e
4 changes: 1 addition & 3 deletions src/SQLite/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function run( $result_file, $args ) {
}
}

fwrite( $handle, sprintf( '-- Dump completed on %s', date('c') ) );
fwrite( $handle, sprintf( '-- Dump completed on %s', gmdate( 'c' ) ) );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwrite() enforces using PHP resource handles. This is a good start, and building on top of that it would be lovely to output that as a simple string for the API consumer to stream-write wherever it needs to. This would play well with the Streaming API I'm exploring for WordPress.

fclose( $handle );

if ( $is_stdout ) {
Expand All @@ -78,8 +78,6 @@ public function run( $result_file, $args ) {
} else {
WP_CLI::success( 'Export complete. File written to ' . $result_file );
}


}

protected function get_create_statement( $table, $translator ) {
Expand Down
5 changes: 3 additions & 2 deletions src/SQLite/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class Import extends Base {


protected $unsupported_arguments = [
'skip-optimization',
'defaults',
Expand All @@ -26,7 +27,7 @@ public function run( $sql_file_path, $args ) {
$this->load_dependencies();
$translator = new WP_SQLite_Translator();

$is_stdin = '-' === $sql_file_path;
$is_stdin = '-' === $sql_file_path;
$import_file = $is_stdin ? 'php://stdin' : $sql_file_path;

foreach ( $this->parse_statements( $import_file ) as $statement ) {
Expand All @@ -37,7 +38,7 @@ public function run( $sql_file_path, $args ) {
}

$imported_from = $is_stdin ? 'STDIN' : $sql_file_path;
WP_CLI::success( sprintf("Imported from '%s'.", $imported_from ) );
WP_CLI::success( sprintf( "Imported from '%s'.", $imported_from ) );
}

/**
Expand Down