Skip to content

Commit dd559d1

Browse files
committed
fix: Use return null as default in validate_file_to_edit()
Replace the default wp_die() with return null to preserve the existing runtime behavior for validate_file() code 2 (absolute Windows drive paths). This gives westonruter the option to revert to the wp_die() approach if preferred.
1 parent 4013816 commit dd559d1

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/wp-admin/includes/file.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ function wp_tempnam( $filename = '', $dir = '' ) {
734734
* @param string $file File the user is attempting to edit.
735735
* @param string[] $allowed_files Optional. Array of allowed files to edit.
736736
* `$file` must match an entry exactly.
737-
* @return string|never Returns the file name on success, dies on failure.
737+
* @return string|null|never Returns the file name on success, null in case of absolute Windows drive paths, and dies on failure.
738738
*/
739739
function validate_file_to_edit( $file, $allowed_files = array() ) {
740740
$code = validate_file( $file, $allowed_files );
@@ -751,8 +751,9 @@ function validate_file_to_edit( $file, $allowed_files = array() ) {
751751
// wp_die( __('Sorry, cannot call files with their real path.' ));
752752

753753
case 3:
754-
default:
755754
wp_die( __( 'Sorry, that file cannot be edited.' ) );
755+
default:
756+
return null;
756757
}
757758
}
758759

0 commit comments

Comments
 (0)