Opened 7 years ago
Last modified 4 days ago
#47068 reopened defect (bug)
get_queried_object() returns null date archives and on homepage with blog on front settings
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 4.7 |
| Component: | Query | Keywords: | has-patch |
| Focuses: | Cc: |
Description
get_queried_object() returns null if permalink is plain.
Attachments (1)
Change History (13)
#1
@
7 years ago
- Resolution set to invalid
- Status changed from new to closed
#2
@
7 years ago
- Resolution invalid deleted
- Status changed from closed to reopened
- Summary changed from get_queried_object() returns null on any page if page permalink is set as plain to get_queried_object() returns null date archives and on homepage with blog on front settings
This ticket was mentioned in Slack in #core by sirlouen. View the logs.
3 weeks ago
#7
@
12 days ago
- Keywords has-patch added
- Version set to trunk
Fixes an issue where WP_Query::get_queried_object() returns null on valid queries.
This patch adds missing queried_object handling for:
- Date archives (year, month, day)
- Homepage when “Your latest posts” is selected
Returning null causes problems in:
- Themes expecting valid queried objects
- Breadcrumb plugins (Yoast, RankMath)
- Conditional templates using queried_object_id
- Custom theme frameworks relying on WP_Query consistency
This patch introduces lightweight stdClass objects for both cases, matching how post type archives and taxonomy queries work, without altering existing behavior.
#8
follow-up:
↓ 10
@
6 days ago
@SirLouen why was the version deleted here? And @iflairwebtechnologies, why was the version set to trunk?
#9
@
6 days ago
- Version changed from trunk to 5.1.1
As a general rule, I don't think the version number should be changed once it's been set, so let's change it back to what it was.
The Version field relates to the version in which the bug was originally discovered. If you’re seeing the same bug in a newer version, mention so in a comment, but please do not change the version number.
#10
in reply to:
↑ 8
@
6 days ago
- Version changed from 5.1.1 to 4.7
Replying to wildworks:
As a general rule, I don't think the version number should be changed once it's been set, so let's change it back to what it was.
The Version field relates to the version in which the bug was originally discovered. If you’re seeing the same bug in a newer version, mention so in a comment, but please do not change the version number.
Back in the day, after reading exactly these docs, I was setting to trunk pretty much every ticket I opened (because 99% of the bugs and issues I found were discovered while using trunk)
But I can't remember which long-standing committer (Peter, Aaron, or Sergey), told me that the version was meant to point out when the bug was introduced, not discovered. I think that these docs must be updated because they are misleading.
From that day, while triaging my components, I remove the version when I'm confident that it's not set to when it was introduced (but I have not dug into it deeper to find the exact moment when it was introduced).
So technically it was minimally introduced in 4.7 (broken by design).
cc @ellatrix
This ticket was mentioned in Slack in #core by sirlouen. View the logs.
4 days ago
#12
@
4 days ago
@wildworks @ellatrix, docs updated. Now it displays introduced. Just FYI 👌
The
If you’re seeing the same bug in a newer version, mention so in a comment, but please do not change the version number.
This was only meant because occasionally the right version was specified, but someone found it again in a newer version and updated the version.
But as a rule of thumb, if we are suspicious that someone opened the ticket adding a wrong version (discovery version), it should be removed or updated to the right one (the introduction version). I think this field is misleading and almost everyone set it wrongly when they come to Trac for first time (me including, I've seen that Aki has cleared half a dozen old tickets from mine, that I created with trunk and I forgot to update)
Sorry this was a problem at my end.