Making WordPress.org

Changeset 14222


Ignore:
Timestamp:
12/02/2024 05:36:59 AM (3 months ago)
Author:
dd32
Message:

Plugin Directory: Better handling for plugin-check output.

See #7840.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php

    r14220 r14222  
    700700            $env_vars
    701701        );
     702        if ( ! $plugin_check_process ) {
     703            // If we can't run plugin-check, we'll just return a pass.
     704            return [
     705                'verdict' => true,
     706                'results' => [],
     707                'html'    => '',
     708            ];
     709        }
    702710        do {
    703711            usleep( 100000 ); // 0.1s
     
    714722        } while ( $proc_status['running'] && $total_time <= 60 ); // 60s max, just in case.
    715723
    716         $output = explode( "\n", stream_get_contents( $pipes[1] ) );
    717         $stderr = rtrim( stream_get_contents( $pipes[2] ) );
     724        $output = stream_get_contents( $pipes[1] );
     725        $stderr = rtrim( stream_get_contents( $pipes[2] ), "\n" );
     726
     727        // Remove ABSPATH from the output if present.
     728        $output = str_replace( ABSPATH, '/', $output );
     729        $output = str_replace( str_replace( '/', '\/', ABSPATH ), '\/', $output ); // JSON encoded
     730        $stderr = str_replace( ABSPATH, '/', $stderr );
    718731
    719732        // Close the process.
    720733        fclose( $pipes[1] );
    721734        fclose( $pipes[2] );
    722         fclose( $plugin_check_process );
     735        proc_close( $plugin_check_process );
    723736
    724737        /**
     
    747760        $verdict  = true;
    748761        $results  = [];
     762        $output   = explode( "\n", $outout );
    749763        foreach ( array_chunk( $output, 3 ) as $file_result ) {
    750764            if ( ! str_starts_with( $file_result[0], 'FILE:' ) ) {
Note: See TracChangeset for help on using the changeset viewer.