Opened 10 years ago
Closed 10 years ago
#26728 closed defect (bug) (fixed)
Previous fix for get_queried_object, gives notices for tax queries
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 3.9 | Priority: | normal |
Severity: | normal | Version: | 3.9 |
Component: | Query | Keywords: | has-patch |
Focuses: | Cc: |
Description (last modified by )
Attachments (3)
Change History (22)
#4
@
10 years ago
- Cc frederic.demarle@… added
I believe that at this point $this->is_tax is always true. So the proposed patch should reintroduce the bug corrected in [26864]. I thus propose to test for:
empty($query['terms'])
instead of only
$query['terms']
That would be strange enough if this notice was not present in WP < 3.8 since [26864] reintroduced the test exactly as it was before [26007].
#5
@
10 years ago
If $this->is_tax is always true, than the line 3265 above will always be true:
if ( $this->is_category || $this->is_tag || $this->is_tax )
And $query is never defined in this function, so it'll always be empty.
#6
@
10 years ago
Seems like this code had a bug to begin with then, as $query is undefined in this function, and $query[ 'terms' ] will never have any content.
Rather than reintroducing a bug, let's determine what the code should be doing here. I cannot see why is_tax would always be true here, except insofar as the check before it was only checking for those cases.
#7
@
10 years ago
26728.diff looks good, but I don't think the check for if ( $query[ 'terms' ] ) is necessary. The field, terms, and taxonomy should all be set at that point from the $tax_query_in_and.
#8
@
10 years ago
#9
@
10 years ago
For what it's worth, $this->is_tax is not always true at this point (from my quick testing).
#10
follow-ups:
↓ 11
↓ 17
@
10 years ago
Seems like 26728.diff would be the correct fix there.
Replying to Chouby:
That would be strange enough if this notice was not present in WP < 3.8 since [26864] reintroduced the test exactly as it was before [26007].
Not exactly, $query
was defined at that point before [26007] (see line 3253 on the left).
Replying to layotte:
If $this->is_tax is always true, than the line 3265 above will always be true:
No, it's vice versa. If we're inside that condition, then either $this->is_category
, $this->is_tag
, or $this->is_tax
is true. We check for $this->is_category
and $this->is_tag
above, so if they are both false, that means $this->is_tax
is true.
Replying to Otto42:
26728.diff looks good, but I don't think the check for if ( $query[ 'terms' ] ) is necessary.
#11
in reply to:
↑ 10
@
10 years ago
Replying to SergeyBiryukov:
Replying to layotte:
If $this->is_tax is always true, than the line 3265 above will always be true:
No, it's vice versa. If we're inside that condition, then either
$this->is_category
,$this->is_tag
, or$this->is_tax
is true. We check for$this->is_category
and$this->is_tag
above, so if they are both false, that means$this->is_tax
is true.
Ah, yes, misunderstood what he meant.
+1 to 26728.diff
This ticket was mentioned in IRC in #wordpress-dev by SergeyBiryukov. View the logs.
10 years ago
#17
in reply to:
↑ 10
;
follow-up:
↓ 18
@
10 years ago
Replying to SergeyBiryukov:
Not exactly,
$query
was defined at that point before [26007] (see line 3253 on the left).
This seems to be what we all missed in previous attempts to solve #26634
Should we close #26634 and mark it as duplicate in favor of this ticket as now the right fix is dealt here?
Makes sense. $query is the wrong thing to use there.