Skip to content

Commit d7c22d2

Browse files
Code Modernization: Check the input type in validate_file().
This fixes a `preg_match_all(): Passing null to parameter #2 ($subject) of type string is deprecated` notice on PHP 8.1. The behavior for `null` and `string` input is covered by the existing `Tests_Functions::test_validate_file()` test. Effect: Errors down by 238, assertions up by 1920, failures down by 1. Props jrf, hellofromTonya, SergeyBiryukov. See #53635. git-svn-id: https://develop.svn.wordpress.org/trunk@51625 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d93f76d commit d7c22d2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/wp-includes/functions.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5709,6 +5709,10 @@ function iis7_supports_permalinks() {
57095709
* @return int 0 means nothing is wrong, greater than 0 means something was wrong.
57105710
*/
57115711
function validate_file( $file, $allowed_files = array() ) {
5712+
if ( ! is_scalar( $file ) || '' === $file ) {
5713+
return 0;
5714+
}
5715+
57125716
// `../` on its own is not allowed:
57135717
if ( '../' === $file ) {
57145718
return 1;

0 commit comments

Comments
 (0)