Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#55400 closed defect (bug) (duplicate)

PHP Warning: Attempt to read property "post_type"

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

Description

Hi,

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?

Thanks!

Attachments (1)

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

Download all attachments as: .zip

Change History (7)

#1 @audrasjb
5 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
5 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.

https://prnt.sc/YvmBGT785JaJ

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

#3 follow-up: @audrasjb
5 years ago

  • Keywords reporter-feedback removed

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

@azouamauriac
5 years ago

#4 in reply to: ↑ 3 @azouamauriac
5 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
5 years ago

Some History: [15531]

#6 @SergeyBiryukov
5 years ago

  • Component General → Query
  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → 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.