WordPress.org

Make WordPress Core

Changeset 51625


Ignore:
Timestamp:
08/16/2021 10:51:47 PM (5 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r51599 r51625  
    57105710 */
    57115711function 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 ) {
Note: See TracChangeset for help on using the changeset viewer.