Opened 6 years ago
Closed 6 years ago
#39215 closed defect (bug) (fixed)
Support for string $args in wp_get_object_terms() broken in 4.7
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.7.1 | Priority: | normal |
Severity: | critical | Version: | 4.7 |
Component: | Taxonomy | Keywords: | has-patch has-unit-tests fixed-major |
Focuses: | Cc: |
Description (last modified by )
It appears that wp_get_object_terms()
no longer supports the string version of the $args
parameter. Prior to WordPress 4.7 it used to support both string and array values, and there might be multiple plugins and themes that rely on this fact. It's also documented as string|array
in the Codex.
After digging a bit I found that this regression has been introduced in [38667] which removed a lot of redundant code.
Attachments (4)
Change History (14)
#1
@
6 years ago
- Keywords has-patch 2nd-opinion needs-testing added
- Severity changed from normal to critical
#2
@
6 years ago
- Keywords 2nd-opinion removed
I've updated the patch, to use wp_parse_args()
instead of explode()
. It's a minimal solution to support string $args
, without default args. To further clarify: prior to 4.7, default values were specified in the wp_parse_args()
call.
#3
@
6 years ago
- Description modified (diff)
- Keywords needs-unit-tests added; needs-testing removed
- Milestone changed from Awaiting Review to 4.7.1
Does someone want to work on a unit test for this?
#5
@
6 years ago
- Keywords has-unit-tests added; needs-unit-tests removed
39215.3.patch includes a unit test that verifies $args
can also be a string
.
#7
@
6 years ago
Note that the
is_string( $args )
check shouldn't be needed here.
Since calling wp_parse_args()
on an array $args
is completely unnecessary, my point was to avoid any overhead that calling wp_parse_args()
on that array would cause. But you're right that wp_parse_args()
will work just fine for arrays as well, so I'm attaching an updated patch.
#8
@
6 years ago
- Owner set to dd32
- Resolution set to fixed
- Status changed from new to closed
In 39578:
Improve initial patch by using
wp_parse_args()
instead ofexplode()