WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/20/2016 11:35:50 PM (4 years ago)
Author:
wonderboymusic
Message:

Media: when calling pathinfo(), also pass a PATHINFO_* constant to avoid array notices for unset keys.

Props JaworskiMatt.
Fixes #37608.

File:
1 edited

Legend:

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

    r38152 r38294  
    20352035
    20362036    // Separate the filename into a name and extension.
    2037     $info = pathinfo($filename);
    2038     $ext = !empty($info['extension']) ? '.' . $info['extension'] : '';
    2039     $name = basename($filename, $ext);
     2037    $ext = pathinfo( $filename, PATHINFO_EXTENSION );
     2038    $name = pathinfo( $filename, PATHINFO_BASENAME );
     2039    if ( $ext ) {
     2040        $ext = '.' . $ext;
     2041    }
    20402042
    20412043    // Edge case: if file is named '.ext', treat as an empty name.
    2042     if ( $name === $ext )
     2044    if ( $name === $ext ) {
    20432045        $name = '';
     2046    }
    20442047
    20452048    /*
Note: See TracChangeset for help on using the changeset viewer.