WordPress.org

Make WordPress Core

Changeset 33447


Ignore:
Timestamp:
07/27/2015 06:04:19 PM (6 years ago)
Author:
markjaquith
Message:

Don't blindly trust the output of glob() to be an array.

props kitchin
fixes #33093

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r33209 r33447  
    10591059        // Check the folder contains at least 1 valid plugin.
    10601060        $plugins_found = false;
    1061         foreach ( glob( $working_directory . '*.php' ) as $file ) {
    1062             $info = get_plugin_data($file, false, false);
    1063             if ( !empty( $info['Name'] ) ) {
    1064                 $plugins_found = true;
    1065                 break;
     1061        $files = glob( $working_directory . '*.php' );
     1062        if ( $files ) {
     1063            foreach ( $files as $file ) {
     1064                $info = get_plugin_data( $file, false, false );
     1065                if ( ! empty( $info['Name'] ) ) {
     1066                    $plugins_found = true;
     1067                    break;
     1068                }
    10661069            }
    10671070        }
  • trunk/src/wp-admin/includes/update-core.php

    r32654 r33447  
    12741274    }
    12751275
    1276     foreach ( glob( $directory . '*', GLOB_ONLYDIR ) as $dir ) {
    1277         $files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) );
     1276    $dirs = glob( $directory . '*', GLOB_ONLYDIR );
     1277    if ( $dirs ) {
     1278        foreach ( $dirs as $dir ) {
     1279            $files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) );
     1280        }
    12781281    }
    12791282
  • trunk/src/wp-includes/l10n.php

    r33230 r33447  
    775775    $languages = array();
    776776
    777     foreach( (array)glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' ) as $lang_file ) {
    778         $lang_file = basename($lang_file, '.mo');
    779         if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) &&
    780             0 !== strpos( $lang_file, 'admin-' ))
    781             $languages[] = $lang_file;
     777    $lang_files = glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' );
     778    if ( $lang_files ) {
     779        foreach( $lang_files as $lang_file ) {
     780            $lang_file = basename( $lang_file, '.mo' );
     781            if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) &&
     782                0 !== strpos( $lang_file, 'admin-' ) ) {
     783                $languages[] = $lang_file;
     784            }
     785        }
    782786    }
    783787
Note: See TracChangeset for help on using the changeset viewer.