Make WordPress Core


Ignore:
Timestamp:
05/19/2021 10:10:58 PM (5 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/taxonomy.php

    r50828 r50935  
    17611761        $value = esc_js( $value );
    17621762    }
     1763
     1764    // Restore the type for integer fields after esc_attr().
     1765    if ( in_array( $field, $int_fields, true ) ) {
     1766        $value = (int) $value;
     1767    }
     1768
    17631769    return $value;
    17641770}
Note: See TracChangeset for help on using the changeset viewer.