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

Props kitchin.

Merge of [33447] to the 4.2 branch.

Fixes #33093.


Built from https://develop.svn.wordpress.org/branches/4.2@33481


git-svn-id: http://core.svn.wordpress.org/branches/4.2@33448 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2015-07-29 06:53:28 +00:00
parent 371f520a52
commit c58e9ddf35
3 changed files with 22 additions and 12 deletions

View File

@ -972,11 +972,14 @@ class Plugin_Upgrader extends WP_Upgrader {
// Check the folder contains at least 1 valid plugin. // Check the folder contains at least 1 valid plugin.
$plugins_found = false; $plugins_found = false;
foreach ( glob( $working_directory . '*.php' ) as $file ) { $files = glob( $working_directory . '*.php' );
$info = get_plugin_data($file, false, false); if ( $files ) {
if ( !empty( $info['Name'] ) ) { foreach ( $files as $file ) {
$plugins_found = true; $info = get_plugin_data( $file, false, false );
break; if ( ! empty( $info['Name'] ) ) {
$plugins_found = true;
break;
}
} }
} }

View File

@ -1249,8 +1249,11 @@ function _upgrade_422_find_genericons_files_in_folder( $directory ) {
$files[] = "{$directory}example.html"; $files[] = "{$directory}example.html";
} }
foreach ( glob( $directory . '*', GLOB_ONLYDIR ) as $dir ) { $dirs = glob( $directory . '*', GLOB_ONLYDIR );
$files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) ); if ( $dirs ) {
foreach ( $dirs as $dir ) {
$files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) );
}
} }
return $files; return $files;

View File

@ -763,11 +763,15 @@ function translate_user_role( $name ) {
function get_available_languages( $dir = null ) { function get_available_languages( $dir = null ) {
$languages = array(); $languages = array();
foreach( (array)glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' ) as $lang_file ) { $lang_files = glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' );
$lang_file = basename($lang_file, '.mo'); if ( $lang_files ) {
if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) && foreach( $lang_files as $lang_file ) {
0 !== strpos( $lang_file, 'admin-' )) $lang_file = basename( $lang_file, '.mo' );
$languages[] = $lang_file; if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) &&
0 !== strpos( $lang_file, 'admin-' ) ) {
$languages[] = $lang_file;
}
}
} }
return $languages; return $languages;