Make WordPress Core

Changeset 54464

Timestamp:
10/10/2022 11:01:08 PM (22 months ago)
Author:
audrasjb
Message:

Query: Prevent PHP notice when get_post_type_object() returns null in is_post_type_archive().

This changeset avoids potential PHP notices caused by get_post_type_object() returning null when called inside is_post_type_archive().

Props sean212, costdev.
Fixes #56287.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-query.php

    r54410 r54464  
    39363936        $post_type_object = get_post_type_object( $post_type );
    39373937
     3938
     3939
     3940
     3941
    39383942        return in_array( $post_type_object->name, (array) $post_types, true );
    39393943    }
  • trunk/tests/phpunit/tests/query.php

    r54090 r54464  
    770770        $this->assertSame( '/* posts_join_request */', $posts_clauses_request['join'] );
    771771    }
     772
     773
     774
     775
     776
     777
     778
     779
     780
     781
     782
     783
     784
     785
     786
     787
     788
     789
     790
    772791}
Note: See TracChangeset for help on using the changeset viewer.