-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embed: Avoid retrying valid URLs #60655
Conversation
Size Change: +33 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
'https://twitter.com/notnownikki/': | ||
MOCK_BAD_EMBED_PROVIDER_RESPONSE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MOCK_CANT_EMBED_RESPONSE
returns a fallback preview.html
, causing the side-effect to be skipped.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you for the quick fix 🙇
URLs that support trailing slashes
https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/
The request is executed only once and the trailing slash is not removed.
URLs that do not support trailing slashes
https://twitter.com/WordPress/
Retry with URL without trailing slash.
P.S. An issue has been reported on the Japanese forum related to this issue. This PR will fix that issue as well.
It was reported as below.
Hi.
I recently updated to Wordpress 6.5.
However, after updating, a problem has occurred where all trailing slashes in internal links (set in embedding blocks) are deleted.
https://example.com/example/ → https://example.com/example
Also, when I discovered the above, I entered the trailing slash and updated the article, but when I reopened the editing screen, the trailing slash had been deleted again.
As a result, a large number of URLs without trailing slashes have accumulated in the redirect target of the plugin "Local Broken Link Checker" and in the Google Search Console "Page has a redirect".
What can I do to resolve the phenomenon where trailing slashes in internal URLs set in embedded blocks are deleted?
What?
Regression: #58007 (comment).
PR fixes the Embed block side-effect for retrying failing URL embeds without trailing slash. The fix prevents unnecessary retries for providers that support trailing slashes.
Why?
The logic had a race condition, causing false runs in the side-effect logic.
When the URL is newly submitted and the
getEmbedPreview
starts the resolution:fetching
flag isfalse
, waiting for meta selectors to return value.cannotEmbed
istrue
. The selector hasn't returned any info related to the previews.preview
isundefined
. Same as above, the selector hasn't returned the value yet.When all these conditions are met while the selector hasn't finished the resolution, the side effect logic runs and unnecessarily retries the URL.
How?
Check if
getEmbedPreview
has resolved the initial URL before attempting the retry.Testing Instructions
https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/
.https://twitter.com/WordPress/
.Testing Instructions for Keyboard
Same.