Skip to content

Commit

Permalink
Avoid the use of @ to silence errors, by checking if the file exists …
Browse files Browse the repository at this point in the history
…before attempting to open it.
  • Loading branch information
dd32 authored Jan 9, 2025
1 parent 31ddf14 commit c6369f8
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1530,8 +1530,9 @@ function get_source_code( $post_id = null, $force_parse = false ) {
}

// Find just the relevant source code
$source_code = '';
$handle = @fopen( get_source_code_root_dir() . $source_file, 'r' );
$source_code = '';
$file_on_disk = get_source_code_root_dir() . $source_file;
$handle = file_exists( $file_on_disk ) ? fopen( $file_on_disk, 'r' ) : false;
if ( $handle ) {
$line = -1;
while ( ! feof( $handle ) ) {
Expand Down

0 comments on commit c6369f8

Please sign in to comment.