Changeset 61465
- Timestamp:
- 01/10/2026 06:36:40 AM (8 weeks ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
src/wp-admin/includes/template.php (modified) (1 diff)
-
src/wp-includes/nav-menu.php (modified) (1 diff)
-
tests/phpunit/tests/admin/includesTemplate.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/template.php
r61463 r61465 2297 2297 function get_post_states( $post ) { 2298 2298 $post_states = array(); 2299 if ( ! $post instanceof WP_Post ) { 2300 return $post_states; 2301 } 2302 2299 2303 $post_status = $_REQUEST['post_status'] ?? ''; 2300 2304 -
trunk/src/wp-includes/nav-menu.php
r61454 r61465 876 876 // Denote post states for special pages (only in the admin). 877 877 if ( function_exists( 'get_post_states' ) ) { 878 $menu_post = get_post( $menu_item->object_id ); 879 $post_states = get_post_states( $menu_post ); 880 if ( $post_states ) { 881 $menu_item->type_label = wp_strip_all_tags( implode( ', ', $post_states ) ); 878 $menu_post = get_post( $menu_item->object_id ); 879 if ( $menu_post instanceof WP_Post ) { 880 $post_states = get_post_states( $menu_post ); 881 if ( $post_states ) { 882 $menu_item->type_label = wp_strip_all_tags( implode( ', ', $post_states ) ); 883 } 882 884 } 883 885 } -
trunk/tests/phpunit/tests/admin/includesTemplate.php
r60253 r61465 495 495 remove_meta_box( 'dashboard2', 'dashboard', 'normal' ); 496 496 } 497 498 /** 499 * Tests that get_post_states() handles a null value gracefully. 500 * 501 * This can happen when get_post() returns null (e.g., when a post 502 * doesn't exist) and that result is passed to get_post_states() 503 * without being checked first. 504 * 505 * @ticket 58932 506 * 507 * @covers ::get_post_states 508 */ 509 public function test_get_post_states_with_null_returns_empty_array() { 510 $result = get_post_states( null ); 511 $this->assertSame( array(), $result, 'get_post_states() should return an empty array when WP_Post is not supplied.' ); 512 } 497 513 }
Note: See TracChangeset
for help on using the changeset viewer.