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

props kitchin
fixes #33093

git-svn-id: https://develop.svn.wordpress.org/trunk@33447 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2015-07-27 18:04:19 +00:00
parent cd4811bf66
commit 3f2b0779f5
3 changed files with 22 additions and 12 deletions

View File

@ -1058,13 +1058,16 @@ 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 ) {
$info = get_plugin_data( $file, false, false );
if ( ! empty( $info['Name'] ) ) {
$plugins_found = true; $plugins_found = true;
break; break;
} }
} }
}
if ( ! $plugins_found ) if ( ! $plugins_found )
return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __( 'No valid plugins were found.' ) ); return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __( 'No valid plugins were found.' ) );

View File

@ -1273,9 +1273,12 @@ 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 );
if ( $dirs ) {
foreach ( $dirs as $dir ) {
$files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) ); $files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) );
} }
}
return $files; return $files;
} }

View File

@ -774,12 +774,16 @@ 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 ) {
foreach( $lang_files as $lang_file ) {
$lang_file = basename( $lang_file, '.mo' );
if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) && if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) &&
0 !== strpos( $lang_file, 'admin-' )) 0 !== strpos( $lang_file, 'admin-' ) ) {
$languages[] = $lang_file; $languages[] = $lang_file;
} }
}
}
return $languages; return $languages;
} }