Make WordPress Core


Ignore:
Timestamp:
05/19/2021 10:10:58 PM (4 years ago)
Author:
SergeyBiryukov
Message:

General: Ensure consistent type for integer properties of WP_Post, WP_Term, and WP_User.

Previously, these properties could be unexpectedly converted to strings in some contexts.

This applies to the following functions:

  • sanitize_post_field()
  • sanitize_term_field()
  • sanitize_user_field()

and the following properties:

  • WP_Post::ID
  • WP_Post::post_parent
  • WP_Post::menu_order
  • WP_Term::term_id
  • WP_Term::term_taxonomy_id
  • WP_Term::parent
  • WP_Term::count
  • WP_Term::term_group
  • WP_User::ID

Props grantmkin, SergeyBiryukov.
Fixes #53235. See #52995.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r50835 r50935  
    26342634    }
    26352635
     2636    // Restore the type for integer fields after esc_attr().
     2637    if ( in_array( $field, $int_fields, true ) ) {
     2638        $value = (int) $value;
     2639    }
     2640
    26362641    return $value;
    26372642}
Note: See TracChangeset for help on using the changeset viewer.