Make WordPress Core

Opened 17 months ago

Closed 16 months ago

Last modified 15 months ago

#57376 closed defect (bug) (fixed)

Fix Mixcloud Embed url

Reported by: matclayton's profile matclayton Owned by: audrasjb's profile audrasjb
Milestone: 6.2 Priority: normal
Severity: normal Version:
Component: Embeds Keywords: has-patch needs-dev-note
Focuses: Cc:

Description

I work at Mixcloud and we are moving some api's about as part of a large hygiene project, the new api is online and we are opening tickets/patches to move over key partners.

https://www.mixcloud.com/oembed/
to
https://app.mixcloud.com/oembed/

Attachments (3)

Capture d’écran 2023-01-10 à 09.25.29.png (449.9 KB) - added by audrasjb 17 months ago.
Test using the current endpoint (www)
Capture d’écran 2023-01-10 à 09.26.04.png (170.1 KB) - added by audrasjb 17 months ago.
Test using the new endpoint (app)
57376.diff (1.1 KB) - added by peterwilsoncc 16 months ago.

Download all attachments as: .zip

Change History (28)

This ticket was mentioned in PR #3799 on WordPress/wordpress-develop by matclayton.


17 months ago
#1

  • Keywords has-patch added

#2 @ayeshrajans
17 months ago

Welcome to Trac, @matclayton.

PR looks good to me.

#3 @matclayton
17 months ago

Thanks, whats the best way to move this forward and get it merged?

#4 @peterwilsoncc
17 months ago

Thanks for the pull request @matclayton!

As part of the clean up, would it be possible to add the oembed discovery headers to the HTML for mixes?

They're detailed in the Discovery section of the oembed specification.

I was testing doing a curl request to https://www.mixcloud.com/FatboySlim/fatboy-slim-live-from-glastonbury-2022-shangrila-gas-tower/ and was unable to see them. It appears they are added via JavaScript.

#5 @matclayton
17 months ago

Thats 100% what we are trying to achieve. Unfortunately its a bit of a mess and a long series of changes. For a broader context we have our own Server side rendering system, which we are repairing, to fix up use cases like this. But to do that we're removing all the apis on that domain to allow us to re-architect fix it cleanly, which is how we got to this PR :)

Suffice to say this PR is one along that journey, ultimately fixing up the discovery headers and other related SSR bugs along the way.

Hopefully we can merge this in without the headers as it'll unblock a lot of other work which will ultimately allow us to fix up discovery and other bugs.

#6 @peterwilsoncc
17 months ago

  • Milestone changed from Awaiting Review to 6.2

Yeah, it should be fine to get in for the next major WordPress release. I've moved it to the milestone.


While you're modifying URLs, something to be aware of is that WordPress caches the oembed endpoint's response when posts are saved. You can see this in the wp_postmeta table.

This means that if you ever move the www.mixcloud.com/widget/iframe/* URLs, old WordPress posts will continue to request them so you'll need to include redirects, maintain them or similar.

Y'all are probably across this but I'd sure feel foolish if it became a problem and I didn't mention it while I had the chance ;)

#7 @matclayton
17 months ago

Hi @peterwilsoncc,

Thanks for the heads up, we 100% plan to support redirects here, interestingly we ended up doing this patch as the oEmbed jetpack code wouldn't follow redirects for the oEmbed endpoint to the new one. Once we'd fixed that they advised we also come and do the same patch over here, to mitigate any issues with 301's not being followed.

Mat

@audrasjb
17 months ago

Test using the current endpoint (www)

@audrasjb
17 months ago

Test using the new endpoint (app)

#8 @audrasjb
17 months ago

  • Keywords reporter-feedback added
  • Owner set to audrasjb
  • Status changed from new to reviewing

Hello @matclayton and thanks for opening this ticket,

I was going to commit this patch, but… is this change already published/live?

I tested the patch and it looks like it doesn't embed Mixcloud content anymore (see screenshots above this comment).

#9 @matclayton
17 months ago

The endpoint is live currently, so I'm not sure what is going on there. you should be able to see the responses on the two versions below and confirm they are identical. Do you have any more exceptions on your end?

Old:
https://www.mixcloud.com/oembed/?url=https://www.mixcloud.com/rez/&format=json
New:
https://app.mixcloud.com/oembed/?url=https://www.mixcloud.com/rez/&format=json

#10 @audrasjb
17 months ago

  • Keywords reporter-feedback removed

Oh, ok. I was probably experiencing a caching issue, sorry for the false alarm.
The patch works fine on my side 👍

#11 @matclayton
17 months ago

Thanks. Appreciate it!

#12 @audrasjb
17 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 55068:

Embeds: Update Mixcloud oEmbed URL to the new domain.

Replaces https://www.mixcloud.com/oembed with https://app.mixcloud.com/oembed.
Mixcloud plan to redirect old URLs to the new endpoint.

Props matclayton, peterwilsoncc, audrasjb, ayeshrajans.
Fixes #57376.

#14 @audrasjb
17 months ago

  • Keywords needs-dev-note added

#15 @jeherve
16 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Coming back to this, I believe there may be an issue with the embed. This may be what caused the problems @audrasjb ran into when he tested the change.

When querying https://www.mixcloud.com/oembed?maxwidth=600&maxheight=750&url=https%3A%2F%2Fwww.mixcloud.com%2FTheBlessedMadonna%2Fwe-still-believe-episode-085-new-release-wall-special%2F&dnt=1&format=json, you get the proper embed response in the body, after being redirected to https://app.mixcloud.com/oembed/?maxwidth=600&maxheight=750&url=https%3A%2F%2Fwww.mixcloud.com%2FTheBlessedMadonna%2Fwe-still-believe-episode-085-new-release-wall-special%2F&dnt=1&format=json
-> This was the query you would have made with the old format (currently in Core).

However, when querying https://app.mixcloud.com/oembed?maxwidth=500&maxheight=750&url=https%3A%2F%2Fwww.mixcloud.com%2FTheBlessedMadonna%2Fwe-still-believe-episode-085-new-release-wall-special%2F&dnt=1&format=json directly, you get an empty body. Notice the missing trailing / before the query parameters in the URL that fails.
-> This is the new embed format introduced with this changeset.

Should we update Core to have that trailing slash, or revert that change in Core to use the old format (that still works with the redirect) until Mixcloud can support URLs both with and without trailing slashes?

Thank you!

#16 @jeherve
16 months ago

Somewhat related: the embeds seem to work when the Gutenberg plugin is active, because Gutenberg still uses the old format:
https://github.com/WordPress/gutenberg/blob/88335dbf42f456b2c89e3fa12ade3d5170100daa/packages/block-library/src/embed/variations.js#L217

#17 @matclayton
16 months ago

@jeherve Thanks for reporting this, I'll get a patch out on www.mixcloud.com to fix this up. They'll be other platforms having the same issue and not just WordPress. Technically the / version is the one we support in the docs, but enough folk will trip up over this, we need to fix it up.

Mat

#18 @matclayton
16 months ago

This fix is now out.

See

https://app.mixcloud.com/oembed?maxwidth=500&maxheight=750&url=https%3A%2F%2Fwww.mixcloud.com%2FTheBlessedMadonna%2Fwe-still-believe-episode-085-new-release-wall-special%2F&dnt=1&format=json

Renders as JSON, we've made it work with and without the /

#19 @peterwilsoncc
16 months ago

Thanks for the prompt fix upstream.

Given the documented endpoint includes a trailing slash, I suggest WordPress uses it per 57376.diff.

#20 @peterwilsoncc
16 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 55243:

Embeds: Use documented mixcloud.com oembed endpoint.

Adds a trailing slash to the mixcloud.com oembed endpoint to match the documented version.

Follow up to [55068].

Props jeherve, matclayton.
Fixes #57376.

#21 @milana_cap
15 months ago

@matclayton @audrasjb Do we have a volunteer to write the Dev note?

#22 follow-up: @matclayton
15 months ago

@milana_cap Sorry I'm not quite sure what you mean by that, what do you need?

I think this could be summed up as:

"Adds a trailing slash to the mixcloud.com oembed endpoint to match the documented version."

As stated above

#23 in reply to: ↑ 22 @milana_cap
15 months ago

Replying to matclayton:

@milana_cap Sorry I'm not quite sure what you mean by that, what do you need?

I think this could be summed up as:

"Adds a trailing slash to the mixcloud.com oembed endpoint to match the documented version."

As stated above

I'm asking because the ticket was labelled with needs-dev-note. Considering how small the change is, this could probably go into mixed Dev note or even just in the Field guide. Thank you.

#24 @audrasjb
15 months ago

This dev note will be handled with the general Embed dev note @milana_cap ;)

#25 @milana_cap
15 months ago

Thank you @audrasjb

Note: See TracTickets for help on using tickets.