Menus: Fix critical errors when the page_on_front and/or page_for_posts options contain references to non-existing posts.

props: hbhalodia, wplindavantol, josklever, audrasjb.
Fixes: #58345.
Built from https://develop.svn.wordpress.org/trunk@56236


git-svn-id: http://core.svn.wordpress.org/trunk@55748 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2023-07-14 21:47:22 +00:00
parent 94b1479a49
commit fe0920e0a3
2 changed files with 13 additions and 6 deletions

View File

@ -432,8 +432,12 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
$front_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0;
$front_page_obj = null;
if ( ! empty( $front_page ) ) {
$front_page_obj = get_post( $front_page );
$front_page_obj = get_post( $front_page );
}
if ( $front_page_obj ) {
$front_page_obj->front_or_home = true;
$important_pages[] = $front_page_obj;
@ -460,11 +464,14 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
$posts_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0;
if ( ! empty( $posts_page ) ) {
$posts_page_obj = get_post( $posts_page );
$posts_page_obj->posts_page = true;
$posts_page_obj = get_post( $posts_page );
$important_pages[] = $posts_page_obj;
$suppress_page_ids[] = $posts_page_obj->ID;
if ( $posts_page_obj ) {
$front_page_obj->posts_page = true;
$important_pages[] = $posts_page_obj;
$suppress_page_ids[] = $posts_page_obj->ID;
}
}
// Insert Privacy Policy Page.

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-beta4-56235';
$wp_version = '6.3-beta4-56236';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.