Skip to content

Commit 10e19a2

Browse files
fix: broaden MariaDB sandbox mode detection
MariaDB 10.11+ can output the sandbox header as /*M!999999\- enable the sandbox mode */. By checking for '999999' and 'sandbox mode' separately, we ensure compatibility across different MariaDB versions and escaping styles.
1 parent 17f5568 commit 10e19a2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/DB_Command.php

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

830-
if ( false !== $first_line && 0 === strpos( $first_line, '/*!999999\- enable the sandbox mode */' ) ) {
830+
if ( false !== $first_line && strpos( $first_line, '999999' ) !== false && strpos( $first_line, 'sandbox mode' ) !== false ) {
831831
WP_CLI::log( 'MariaDB sandbox mode directive detected. Skipping it by piping the file content.' );
832832
$preamble = $this->get_sql_mode_query( $assoc_args ) . "\n";
833833
if ( ! Utils\get_flag_value( $assoc_args, 'skip-optimization' ) ) {
@@ -846,16 +846,16 @@ public function import( $args, $assoc_args ) {
846846
escapeshellarg( $postamble )
847847
);
848848

849-
// Ensure we don't pass 'execute' which would conflict with STDIN.
850-
unset( $mysql_args['execute'] );
849+
// Ensure we don't pass 'execute' which would conflict with STDIN.
850+
unset( $mysql_args['execute'] );
851851

852-
$result = self::run( $command, $mysql_args );
852+
$result = self::run( $command, $mysql_args );
853853

854-
self::run( $command, $mysql_args );
854+
self::run( $command, $mysql_args );
855855

856-
WP_CLI::success( sprintf( "Imported from '%s'.", $result_file ) );
856+
WP_CLI::success( sprintf( "Imported from '%s'.", $result_file ) );
857857

858-
return;
858+
return;
859859
}
860860

861861
$query = Utils\get_flag_value( $assoc_args, 'skip-optimization' )

0 commit comments

Comments
 (0)