Skip to content

Commit acbe705

Browse files
committed
Avoid nested loops
1 parent bea936a commit acbe705

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/DB_Command_SQLite.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,8 @@ protected function sqlite_import( $file, $assoc_args ) {
494494
$command_parts[] = 'PRAGMA journal_mode=MEMORY;';
495495
}
496496

497+
$command_parts[] = '-init';
498+
$command_parts[] = $import_file;
497499
$command_parts[] = $db_path;
498500

499501
// Build a properly escaped string command. Process::create() requires a string, not an array.
@@ -502,8 +504,8 @@ protected function sqlite_import( $file, $assoc_args ) {
502504
...$command_parts
503505
);
504506

505-
// Pass the .read dot-command as a single quoted argument (sqlite3 reads it as SQL input).
506-
$command .= ' ' . escapeshellarg( ".read '" . $import_file . "'" );
507+
// Pass .exit to quit interactive mode after running -init.
508+
$command .= ' ' . escapeshellarg( '.exit' );
507509

508510
WP_CLI::debug( "Running shell command: {$command}", 'db' );
509511

0 commit comments

Comments
 (0)