Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Warning in CommandWithTranslation #60

Closed
swissspidy opened this issue Sep 27, 2018 · 1 comment
Closed

PHP Warning in CommandWithTranslation #60

swissspidy opened this issue Sep 27, 2018 · 1 comment

Comments

@swissspidy
Copy link
Member

I'm currently getting the following PHP warnings when updating language packs on a site:

PHP Warning:  Invalid argument supplied for foreach() in phar:///usr/bin/wp/vendor/wp-cli/language-command/src/WP_CLI/CommandWithTranslation.php on line 95
Warning: Invalid argument supplied for foreach() in phar:///usr/bin/wp/vendor/wp-cli/language-command/src/WP_CLI/CommandWithTranslation.php on line 95
Success: Updated 0/0 translations.

The code in question is here:

$obj_type = rtrim( $this->obj_type, 's' );
$available_updates = $updates_per_type[ $obj_type ];
$num_to_update += count( $available_updates );
if ( ! Utils\get_flag_value( $assoc_args, 'dry-run' ) ) {
// Update translations.
foreach ( $available_updates as $update ) {
WP_CLI::line( "Updating '{$update->Language}' translation for {$update->Name} {$update->Version}..." );
$result = Utils\get_upgrader( $upgrader )->upgrade( $update );
$results[] = $result;
}
}
}

Looks like the code currently doesn't check whether $available_updates is actually set or is an array. We could add a continue statement in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants