Make WordPress Core

Changeset 56236


Ignore:
Timestamp:
07/14/2023 09:45:05 PM (12 months ago)
Author:
azaozz
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/nav-menu.php

    r56176 r56236  
    433433
    434434        $front_page_obj = null;
     435
    435436        if ( ! empty( $front_page ) ) {
    436             $front_page_obj                = get_post( $front_page );
     437            $front_page_obj = get_post( $front_page );
     438        }
     439
     440        if ( $front_page_obj ) {
    437441            $front_page_obj->front_or_home = true;
    438442
     
    461465
    462466        if ( ! empty( $posts_page ) ) {
    463             $posts_page_obj             = get_post( $posts_page );
    464             $posts_page_obj->posts_page = true;
    465 
    466             $important_pages[]   = $posts_page_obj;
    467             $suppress_page_ids[] = $posts_page_obj->ID;
     467            $posts_page_obj = get_post( $posts_page );
     468
     469            if ( $posts_page_obj ) {
     470                $front_page_obj->posts_page = true;
     471
     472                $important_pages[]   = $posts_page_obj;
     473                $suppress_page_ids[] = $posts_page_obj->ID;
     474            }
    468475        }
    469476
Note: See TracChangeset for help on using the changeset viewer.