Make WordPress Core

Opened 2 years ago

Closed 22 months ago

Last modified 22 months ago

#56287 closed defect (bug) (fixed)

Handle PHP Notice when get_post_type_object() returns null in is_post_type_archive()

Reported by: sean212's profile sean212 Owned by: audrasjb's profile audrasjb
Milestone: 6.1 Priority: normal
Severity: normal Version:
Component: Query Keywords: php8 has-patch has-unit-tests
Focuses: Cc:

Description

When get_post_type_object() is called inside is_post_type_archive() it can return null and will potentially throw a PHP notice.

Relates to #29660 but isn't specific to get_queried_object() so I figured it might be worthwhile to track separately.

Change History (8)

#1 @sean212
2 years ago

  • Summary changed from Handle PHP Notice when get_post_type_object() returns null to Handle PHP Notice when get_post_type_object() returns null in is_post_type_archive()

This ticket was mentioned in PR #3027 on WordPress/wordpress-develop by srtfisher.


2 years ago
#2

  • Keywords has-patch has-unit-tests added

#3 @davidbaumwald
2 years ago

  • Milestone changed from Awaiting Review to 6.1

#4 @costdev
2 years ago

  • Keywords changes-requested added

srtfisher commented on PR #3027:


2 years ago
#5

@costdev Thanks for the review! Changes made.

#6 @sean212
2 years ago

  • Keywords changes-requested removed

Changes made, thanks!

#7 @audrasjb
22 months ago

  • Owner set to audrasjb
  • Resolution set to fixed
  • Status changed from assigned to closed

In 54464:

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.

Note: See TracTickets for help on using tickets.