Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#55400 closed defect (bug) (duplicate)

PHP Warning: Attempt to read property "post_type"

Reported by: stcn's profile stcn Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords: has-patch
Focuses: Cc:



I get this error:

PHP Warning:  Attempt to read property "post_type" on null in /public_html/wp-includes/class-wp-query.php on line 4273

what is the problem? how can it be solved?


Attachments (1)

55400.diff (464 bytes) - added by azouamauriac 2 years ago.

Download all attachments as: .zip

Change History (7)

#1 @audrasjb
2 years ago

  • Keywords reporter-feedback added

Hello and welcome to WordPress Core Trac @stcn,

Could you please provide more information to help contextualize the issue?
Where does it happen? Could you provide a screenshot? Any particular action on you side? Does it occurs with a default theme and no plugin activated?

Thank you

#2 @azouamauriac
2 years ago

  • Keywords needs-patch added

Hi there and welcome to trac!

It seems like we need some if statement in WP_Query::is_singular at line 4292 since WP_Query::get_queried_object can return null I guess it was caused that.

Last edited 2 years ago by azouamauriac (previous) (diff)

#3 follow-up: @audrasjb
2 years ago

  • Keywords reporter-feedback removed

Oh nice catch @azouamauriac. Wanna propose a patch for this issue?

2 years ago

#4 in reply to: ↑ 3 @azouamauriac
2 years ago

  • Keywords has-patch added; needs-patch removed

Replying to audrasjb:

Oh nice catch @azouamauriac. Wanna propose a patch for this issue?

Done! Please let me know if it's fit for you.

#5 @azouamauriac
2 years ago

Some History: [15531]

#6 @SergeyBiryukov
2 years ago

  • Component changed from General to Query
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, welcome to WordPress Trac!

Thanks for the report and the patch, we're already tracking this issue in #29660.

Note: See TracTickets for help on using tickets.