Skip to content

Commit 17f5568

Browse files
Fix: Remove explicit exit_code check and handle potential false from fgets
1 parent 65ef54c commit 17f5568

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/DB_Command.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -827,9 +827,8 @@ public function import( $args, $assoc_args ) {
827827
$first_line = fgets( $fp );
828828
fclose( $fp );
829829

830-
if ( 0 === strpos( $first_line, '/*!999999\- enable the sandbox mode */' ) ) {
830+
if ( false !== $first_line && 0 === strpos( $first_line, '/*!999999\- enable the sandbox mode */' ) ) {
831831
WP_CLI::log( 'MariaDB sandbox mode directive detected. Skipping it by piping the file content.' );
832-
833832
$preamble = $this->get_sql_mode_query( $assoc_args ) . "\n";
834833
if ( ! Utils\get_flag_value( $assoc_args, 'skip-optimization' ) ) {
835834
$preamble .= "SET autocommit = 0; SET unique_checks = 0; SET foreign_key_checks = 0;\n";
@@ -852,11 +851,9 @@ public function import( $args, $assoc_args ) {
852851

853852
$result = self::run( $command, $mysql_args );
854853

855-
if ( 0 === $result['exit_code'] ) {
856-
WP_CLI::success( sprintf( "Imported from '%s'.", $result_file ) );
857-
} else {
858-
WP_CLI::error( sprintf( "Failed to import from '%s'.", $result_file ) );
859-
}
854+
self::run( $command, $mysql_args );
855+
856+
WP_CLI::success( sprintf( "Imported from '%s'.", $result_file ) );
860857

861858
return;
862859
}

0 commit comments

Comments
 (0)