Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Comment_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public function __construct() {
* # Create comment.
* $ wp comment create --comment_post_ID=15 --comment_content="hello blog" --comment_author="wp-cli"
* Success: Created comment 932.
*
* @param string[] $args Positional arguments. Unused.
* @param array<string, mixed> $assoc_args Associative arguments.
*/
public function create( $args, $assoc_args ) {
$assoc_args = wp_slash( $assoc_args );
Expand Down Expand Up @@ -110,6 +113,9 @@ function ( $params ) {
* # Update comment.
* $ wp comment update 123 --comment_author='That Guy'
* Success: Updated comment 123.
*
* @param string[] $args Positional arguments. Comment IDs to update.
* @param array<string, mixed> $assoc_args Associative arguments.
*/
public function update( $args, $assoc_args ) {
$assoc_args = wp_slash( $assoc_args );
Expand Down
25 changes: 20 additions & 5 deletions src/Term_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,14 @@ public function list_( $args, $assoc_args ) {
/**
* @var \WP_Term[] $terms
*/
// phpcs:ignore WordPress.WP.DeprecatedParameters.Get_termsParam2Found -- Required for backward compatibility.
$terms = get_terms( $args, $assoc_args );
$terms = get_terms(
array_merge(
$assoc_args,
[
'taxonomy' => $args,
]
)
);
}

$terms = array_map(
Expand Down Expand Up @@ -211,7 +217,11 @@ public function create( $args, $assoc_args ) {

$assoc_args = wp_slash( $assoc_args );
$term = wp_slash( $term );
$result = wp_insert_term( $term, $taxonomy, $assoc_args );

/**
* @var string $term
*/
$result = wp_insert_term( $term, $taxonomy, $assoc_args );

if ( is_wp_error( $result ) ) {
WP_CLI::error( $result->get_error_message() );
Expand Down Expand Up @@ -643,8 +653,13 @@ public function recount( $args ) {
* @var \WP_Term[] $terms
*/

// phpcs:ignore WordPress.WP.DeprecatedParameters.Get_termsParam2Found -- Required for backward compatibility.
$terms = get_terms( $taxonomy, [ 'hide_empty' => false ] );
$terms = get_terms(
[
'taxonomy' => $taxonomy,
'hide_empty' => false,
]
);

$term_taxonomy_ids = wp_list_pluck( $terms, 'term_taxonomy_id' );

wp_update_term_count( $term_taxonomy_ids, $taxonomy );
Expand Down
3 changes: 3 additions & 0 deletions src/User_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,9 @@ public function create( $args, $assoc_args ) {
* # Update user
* $ wp user update 123 --display_name=Mary --user_pass=marypass
* Success: Updated user 123.
*
* @param string[] $args Positional arguments. Users to update.
* @param array $assoc_args Associative arguments.
*/
public function update( $args, $assoc_args ) {
if ( isset( $assoc_args['user_login'] ) ) {
Expand Down
6 changes: 6 additions & 0 deletions src/WP_CLI/CommandWithMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ public function update( $args, $assoc_args ) {

$object_id = $this->check_object_id( $object_id );

/**
* @var array|string $meta_value
*/
$meta_value = sanitize_meta( $meta_key, $meta_value, $this->meta_type );
$old_value = sanitize_meta( $meta_key, $this->get_metadata( $object_id, $meta_key, true ), $this->meta_type );

Expand Down Expand Up @@ -454,6 +457,9 @@ function ( $key ) {
WP_CLI::error( $exception->getMessage() );
}

/**
* @var array|string $patched_meta_value
*/
$patched_meta_value = sanitize_meta( $meta_key, $traverser->value(), $this->meta_type );

if ( $patched_meta_value === $old_meta_value ) {
Expand Down