Make WordPress Core

Changeset 33481


Ignore:
Timestamp:
07/29/2015 06:52:42 AM (11 years ago)
Author:
pento
Message:

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

Props kitchin.

Merge of [33447] to the 4.2 branch.

Fixes #33093.

Location:
branches/4.2/src
Files:
3 edited

Legend:

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

    r31991 r33481  
    973973                // Check the folder contains at least 1 valid plugin.
    974974                $plugins_found = false;
    975                 foreach ( glob( $working_directory . '*.php' ) as $file ) {
    976                         $info = get_plugin_data($file, false, false);
    977                         if ( !empty( $info['Name'] ) ) {
    978                                 $plugins_found = true;
    979                                 break;
     975                $files = glob( $working_directory . '*.php' );
     976                if ( $files ) {
     977                        foreach ( $files as $file ) {
     978                                $info = get_plugin_data( $file, false, false );
     979                                if ( ! empty( $info['Name'] ) ) {
     980                                        $plugins_found = true;
     981                                        break;
     982                                }
    980983                        }
    981984                }
  • branches/4.2/src/wp-admin/includes/update-core.php

    r32386 r33481  
    12501250        }
    12511251
    1252         foreach ( glob( $directory . '*', GLOB_ONLYDIR ) as $dir ) {
    1253                 $files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) );
     1252        $dirs = glob( $directory . '*', GLOB_ONLYDIR );
     1253        if ( $dirs ) {
     1254                foreach ( $dirs as $dir ) {
     1255                        $files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) );
     1256                }
    12541257        }
    12551258
  • branches/4.2/src/wp-includes/l10n.php

    r31447 r33481  
    764764        $languages = array();
    765765
    766         foreach( (array)glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' ) as $lang_file ) {
    767                 $lang_file = basename($lang_file, '.mo');
    768                 if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) &&
    769                         0 !== strpos( $lang_file, 'admin-' ))
    770                         $languages[] = $lang_file;
     766        $lang_files = glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' );
     767        if ( $lang_files ) {
     768                foreach( $lang_files as $lang_file ) {
     769                        $lang_file = basename( $lang_file, '.mo' );
     770                        if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) &&
     771                                0 !== strpos( $lang_file, 'admin-' ) ) {
     772                                $languages[] = $lang_file;
     773                        }
     774                }
    771775        }
    772776
Note: See TracChangeset for help on using the changeset viewer.