Opened 5 years ago
Closed 5 years ago
#49988 closed defect (bug) (fixed)
Incorrect usage of `get_home_url` in PHPUnit tests
Reported by: | david.binda | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Embeds | Keywords: | |
Focuses: | Cc: |
Description
The Tests_oEmbed_Response_Data
class uses the get_home_url
incorrectly on multiple places.
The function is being called with '/'
passed to it as first param.
However, the first param should be a $blog_id
(either null
or int
), and is used for a call to switch_to_blog
.
So, calling the get_home_url( '/' )
attempts to switch to blog '/'
which fails, and URL of the current blog is being returned, but the trailing slash is not being appended.
Which leads to the second issue with those tests - they are actually passing without the trailing slash being added, which I guess is expected (at least accordingly to the code generating actual data: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/embed.php?annotate=blame#L548 )
Fix should be as easy as removing the param passed to get_home_url
function call, as it's being done in attached patch.
Thanks for the patch!
It looks like the intention might have been to use
home_url()
instead. Introduced in [34903].