File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -816,6 +816,27 @@ public function import( $args, $assoc_args ) {
816816 if ( ! is_readable ( $ result_file ) ) {
817817 WP_CLI ::error ( sprintf ( 'Import file missing or not readable: %s ' , $ result_file ) );
818818 }
819+
820+ // Check for MariaDB sandbox directive and skip it if found
821+ $ first_line = fgets ( fopen ( $ result_file , 'r ' ) );
822+ if ( strpos ( $ first_line , '/*!999999 \\' ) !== false ) {
823+ WP_CLI ::debug ( 'MariaDB sandbox directive found. Creating sanitized temp file. ' , 'db ' );
824+
825+ $ input = fopen ( $ result_file , 'r ' );
826+ $ tmp = tmpfile ();
827+ $ tmp_path = stream_get_meta_data ( $ tmp )['uri ' ];
828+
829+ $ line_number = 0 ;
830+ while ( ( $ line = fgets ( $ input ) ) !== false ) {
831+ if ( $ line_number > 0 ) {
832+ fwrite ( $ tmp , $ line );
833+ }
834+ $ line_number ++;
835+ }
836+ fclose ( $ input );
837+
838+ $ result_file = $ tmp_path ;
839+ }
819840
820841 $ query = Utils \get_flag_value ( $ assoc_args , 'skip-optimization ' )
821842 ? 'SOURCE %s; '
You can’t perform that action at this time.
0 commit comments