Changeset 50935
- Timestamp:
- 05/19/2021 10:10:58 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r50835 r50935 2634 2634 } 2635 2635 2636 // Restore the type for integer fields after esc_attr(). 2637 if ( in_array( $field, $int_fields, true ) ) { 2638 $value = (int) $value; 2639 } 2640 2636 2641 return $value; 2637 2642 } -
trunk/src/wp-includes/taxonomy.php
r50828 r50935 1761 1761 $value = esc_js( $value ); 1762 1762 } 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 1763 1769 return $value; 1764 1770 } -
trunk/src/wp-includes/user.php
r50916 r50935 1531 1531 $value = esc_js( $value ); 1532 1532 } 1533 1534 // Restore the type for integer fields after esc_attr(). 1535 if ( in_array( $field, $int_fields, true ) ) { 1536 $value = (int) $value; 1537 } 1538 1533 1539 return $value; 1534 1540 } -
trunk/tests/phpunit/tests/post/objects.php
r48937 r50935 185 185 } 186 186 187 /** 188 * @ticket 53235 189 */ 190 public function test_numeric_properties_should_be_cast_to_ints() { 191 $post_id = self::factory()->post->create(); 192 $contexts = array( 'raw', 'edit', 'db', 'display', 'attribute', 'js' ); 193 194 foreach ( $contexts as $context ) { 195 $post = get_post( $post_id, OBJECT, $context ); 196 197 $this->assertInternalType( 'int', $post->ID ); 198 $this->assertInternalType( 'int', $post->post_parent ); 199 $this->assertInternalType( 'int', $post->menu_order ); 200 } 201 } 202 187 203 function test_get_post_identity() { 188 204 $post = get_post( self::factory()->post->create() ); -
trunk/tests/phpunit/tests/term/getTerm.php
r50926 r50935 125 125 /** 126 126 * @ticket 14162 127 * @ticket 53235 127 128 */ 128 129 public function test_numeric_properties_should_be_cast_to_ints() { … … 134 135 $term_data = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms t JOIN $wpdb->term_taxonomy tt ON ( t.term_id = tt.term_id ) WHERE t.term_id = %d", $t ) ); 135 136 136 $found = get_term( $term_data ); 137 138 $this->assertInstanceOf( 'WP_Term', $found ); 139 $this->assertInternalType( 'int', $found->term_id ); 140 $this->assertInternalType( 'int', $found->term_taxonomy_id ); 141 $this->assertInternalType( 'int', $found->parent ); 142 $this->assertInternalType( 'int', $found->count ); 143 $this->assertInternalType( 'int', $found->term_group ); 137 $contexts = array( 'raw', 'edit', 'db', 'display', 'rss', 'attribute', 'js' ); 138 139 foreach ( $contexts as $context ) { 140 $found = get_term( $term_data, '', OBJECT, $context ); 141 142 $this->assertInstanceOf( 'WP_Term', $found ); 143 $this->assertInternalType( 'int', $found->term_id ); 144 $this->assertInternalType( 'int', $found->term_taxonomy_id ); 145 $this->assertInternalType( 'int', $found->parent ); 146 $this->assertInternalType( 'int', $found->count ); 147 $this->assertInternalType( 'int', $found->term_group ); 148 } 144 149 } 145 150 -
trunk/tests/phpunit/tests/user.php
r49757 r50935 203 203 foreach ( get_object_vars( $user ) as $key => $value ) { 204 204 $this->assertSame( $value, $user->$key ); 205 } 206 } 207 208 /** 209 * @ticket 53235 210 */ 211 public function test_numeric_properties_should_be_cast_to_ints() { 212 $user = new WP_User( self::$author_id ); 213 $contexts = array( 'raw', 'edit', 'db', 'display', 'attribute', 'js' ); 214 215 foreach ( $contexts as $context ) { 216 $user->filter = $context; 217 $user->init( $user->data ); 218 219 $this->assertInternalType( 'int', $user->ID ); 205 220 } 206 221 }
Note: See TracChangeset
for help on using the changeset viewer.