Skip to content

False positive when slashing data for wp_insert_post() and wp_update_post() #54

Open
@Chouby

Description

@Chouby

wp_insert_post() is expecting slashed data. So I'm used to prepare data passed to wp_insert_post() and wp_update_post() with wp_slash().
Here is a small sample to demonstrate the issue:

$post = get_post( $post_id, ARRAY_A );
$post['post_status'] = 'draft';
wp_update_post( wp_slash( $post ) );

Since the version 6.0.2 (I suppose since #49), PHPStan reports the following error on:

Parameter #1 $postarr of function wp_update_post expects
  array{ID?: int, post_author?: int, post_date?: string, post_date_gmt?: string, post_content?: string, post_content_filtered?: string, post_title?: string, post_excerpt?: string, ...},
  array<string, string> given.

If I remove wp_slash(), PHPstan would report nothing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions