Opened 7 years ago
Closed 6 years ago
#43521 closed defect (bug) (fixed)
Excluded terms filter in get_adjacent_post is not executed if excluded_terms parameter is empty
Reported by: | zottto | Owned by: | pento |
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | 4.9.4 |
Component: | Posts, Post Types | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
The filter get_previous_post_excluded_terms
/ get_next_post_excluded_terms
is only executed if the parameter $excluded_terms
of get_adjacent_post
(resp. get_previous_post
/ get_next_post
) is set.
If $exclued_terms
is not set (e.g. because the parameter is optional) it is not possible to change the list of excluded terms.
Expected behaviour: The filter should also be executed with an empty $exclided_terms
list to be able to add terms to this list.
The apply_filter
is called within a condition if ( $in_same_term || ! empty( $excluded_terms ) )
which is not met if the parameter is empty.
Attachments (4)
Change History (13)
#2
@
7 years ago
- Component changed from General to Posts, Post Types
- Milestone changed from Awaiting Review to 5.0
#3
@
7 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 42828:
#4
@
7 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Hi, thanks for fixing the bug so fast.
But in my opinion there is now another change in the behaviour of the filter.
Before the fix, the filter was applied only to an array of term IDs. Now the filter is applied before the backwards compatibility part that changes the old usage of term IDs concatenated with "and" to an array.
If the filter is executed now it could happen that the term IDs handled in the filter are in the old style which was not possible before.
From my point of view it would be better to apply the filter after that back-compat part (or to execute the back-compat part before the filter, whatever makes more sense).
#6
@
7 years ago
43521.3.diff includes the test as well, making sure the filter does not error out when a string is passed in (implying that the block of code that transforms the string into the array was run).
Thanks.
Patch + tests