Skip to content

Should setup_postdata trigger an error for overriding WP global? #842

@grappler

Description

@grappler

While preparing to merge the WP Globals check for the WordPress-Theme ruleset I found a place when setup_postdata() is used an error is triggered.

Should the following code trigger an error?

global $post;
$post = get_post( '10' );
setup_postdata( $post );
wp_reset_postdata();

This is also used in Twenty Seventeen https://github.com/WordPress/WordPress/blob/master/wp-content/themes/twentyseventeen/inc/template-tags.php#L142

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions