mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-06 21:54:28 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@50935 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -205,6 +205,21 @@ class Tests_User extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 53235
|
||||
*/
|
||||
public function test_numeric_properties_should_be_cast_to_ints() {
|
||||
$user = new WP_User( self::$author_id );
|
||||
$contexts = array( 'raw', 'edit', 'db', 'display', 'attribute', 'js' );
|
||||
|
||||
foreach ( $contexts as $context ) {
|
||||
$user->filter = $context;
|
||||
$user->init( $user->data );
|
||||
|
||||
$this->assertInternalType( 'int', $user->ID );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the magic __unset() method.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user