diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index acab417d3b..5d2370d090 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -972,11 +972,14 @@ class Plugin_Upgrader extends WP_Upgrader { // Check the folder contains at least 1 valid plugin. $plugins_found = false; - foreach ( glob( $working_directory . '*.php' ) as $file ) { - $info = get_plugin_data($file, false, false); - if ( !empty( $info['Name'] ) ) { - $plugins_found = true; - break; + $files = glob( $working_directory . '*.php' ); + if ( $files ) { + foreach ( $files as $file ) { + $info = get_plugin_data( $file, false, false ); + if ( ! empty( $info['Name'] ) ) { + $plugins_found = true; + break; + } } } diff --git a/wp-admin/includes/update-core.php b/wp-admin/includes/update-core.php index a15cc887e1..04cd780b21 100644 --- a/wp-admin/includes/update-core.php +++ b/wp-admin/includes/update-core.php @@ -1249,8 +1249,11 @@ function _upgrade_422_find_genericons_files_in_folder( $directory ) { $files[] = "{$directory}example.html"; } - foreach ( glob( $directory . '*', GLOB_ONLYDIR ) as $dir ) { - $files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) ); + $dirs = glob( $directory . '*', GLOB_ONLYDIR ); + if ( $dirs ) { + foreach ( $dirs as $dir ) { + $files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) ); + } } return $files; diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index 4c5d8b19a5..339602b1e8 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -763,11 +763,15 @@ function translate_user_role( $name ) { function get_available_languages( $dir = null ) { $languages = array(); - foreach( (array)glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' ) as $lang_file ) { - $lang_file = basename($lang_file, '.mo'); - if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) && - 0 !== strpos( $lang_file, 'admin-' )) - $languages[] = $lang_file; + $lang_files = glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' ); + if ( $lang_files ) { + foreach( $lang_files as $lang_file ) { + $lang_file = basename( $lang_file, '.mo' ); + if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) && + 0 !== strpos( $lang_file, 'admin-' ) ) { + $languages[] = $lang_file; + } + } } return $languages;