Skip to content
Open
Changes from all commits
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
44 changes: 24 additions & 20 deletions components/Blueprints/Steps/class-importcontentstep.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,31 @@ private function importWxr( Runtime $runtime, array $content_definition, Tracker
$import_process->start();

$output = $import_process->getOutputStream( Process::OUTPUT_FILE );
foreach ( $this->output_lines( $output ) as $line ) {
$data = @json_decode( $line, true );
if ( ! is_array( $data ) ) {
// Non-JSON output is treated as a crash. We use a dedicated file pipe
// for communication and it should never contain a non-JSON line.
$import_process->stop();
throw new ProcessFailedException( $import_process );
}
// Report progress, errors, etc.
switch ( $data['type'] ?? '**MISSING**' ) {
case 'progress':
$progress->set( $data['progress'], 'Importing WXR file: ' . $data['caption'] );
break;
case 'error':
throw new BlueprintExecutionException( $data['message'] );
case 'completion':
$progress->finish();
break;
default:
throw new BlueprintExecutionException( 'Unknown message type: ' . $data['type'] );
try {
foreach ( $this->output_lines( $output ) as $line ) {
$data = @json_decode( $line, true );
if ( ! is_array( $data ) ) {
// Non-JSON output is treated as a crash. We use a dedicated file pipe
// for communication and it should never contain a non-JSON line.
$import_process->stop();
throw new ProcessFailedException( $import_process );
}
// Report progress, errors, etc.
switch ( $data['type'] ?? '**MISSING**' ) {
case 'progress':
$progress->set( $data['progress'], 'Importing WXR file: ' . $data['caption'] );
break;
case 'error':
throw new BlueprintExecutionException( $data['message'] );
case 'completion':
$progress->finish();
break;
default:
throw new BlueprintExecutionException( 'Unknown message type: ' . $data['type'] );
}
}
} finally {
$output->close_reading();
}

if ( 0 !== $import_process->getExitCode() ) {
Expand Down
Loading