Make WordPress Core

Opened 6 years ago

Last modified 5 years ago

#46559 reopened defect (bug)

Could not embed some content

Reported by: krstarica's profile Krstarica Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Embeds Keywords:
Focuses: Cc:

Description

When trying to embed https://www.instagram.com/p/Br3FKiDAqCs/ to freshly installed WordPress it says: Sorry, we could not embed that content.

Embedding other Instagram posts usually work.

In wp_postmeta table, appropriate meta_key _oembed_... has meta_value {{unknown}}

Using utf8mb4_unicode_ci collation for both meta_key and meta_value fields.

Maybe this has something to do with emojis, like #36456.

Change History (5)

#1 @desrosj
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed
  • Version 5.1 deleted

Hi @Krstarica,

I am not seeing the issue that you are describing above. In the block editor, I paste the URL into a paragraph block and it converts to an Instagram embed block and correctly shows the content.

I am going to close this out as a worksforme since I can't reproduce the issue. I recommend opening a ticket in the WordPress.org support forums to troubleshoot further. If you are able to determine that this is in fact a bug in core, please reopen with more specific detailed steps to reproduce the issue.

#2 @Krstarica
6 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Hi @desrosj,

I've debugged the issue and found two causes.

1) Getting http_request_failed due to cURL error 28: Operation timed out after 5000 milliseconds with 2594 out of 2818 bytes received error.

WordPress uses the following code in wp-includes/Requests/Transport/cURL.php:

...
curl_setopt($this->handle, CURLOPT_ENCODING, '');
...
curl_setopt($this->handle, CURLOPT_BUFFERSIZE, Requests::BUFFER_SIZE);

Combination of above parameters triggers timeouts fetching some URLs like the one reported using cURL version 7.29.0. This is rather old cURL, but it is bundled with CentOS 7.6.

Workaround is to comment out line:

curl_setopt($this->handle, CURLOPT_ENCODING, '');

but the problem sometimes still happens, although less frequently.

Upgraded to cURL 7.64.1 and things are slightly faster, but didn't resolve the issue completely.

2) Instagram oEmbed API redirects several times:

wget "https://api.instagram.com/oembed?maxwidth=696&maxheight=1000&url=https%3A%2F%2Fwww.instagram.com%2Fp%2FBvmdPLyBFjh%2F&dnt=1&format=json"
--2019-03-31 16:16:04--  https://api.instagram.com/oembed?maxwidth=696&maxheight=1000&url=https%3A%2F%2Fwww.instagram.com%2Fp%2FBvmdPLyBFjh%2F&dnt=1&format=json
Resolving api.instagram.com (api.instagram.com)... 31.13.64.52, 2a03:2880:f206:c4:face:b00c:0:43fe
Connecting to api.instagram.com (api.instagram.com)|31.13.64.52|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://api.instagram.com/publicapi/oembed/?maxwidth=696&maxheight=1000&url=https%3A%2F%2Fwww.instagram.com%2Fp%2FBvmdPLyBFjh%2F&dnt=1&format=json [following]
--2019-03-31 16:16:04--  https://api.instagram.com/publicapi/oembed/?maxwidth=696&maxheight=1000&url=https%3A%2F%2Fwww.instagram.com%2Fp%2FBvmdPLyBFjh%2F&dnt=1&format=json
Reusing existing connection to api.instagram.com:443.
HTTP request sent, awaiting response... 302 Found
Location: https://www.instagram.com/publicapi/oembed/?maxwidth=696&maxheight=1000&url=https://www.instagram.com/p/BvmdPLyBFjh/&dnt=1&format=json [following]
--2019-03-31 16:16:04--  https://www.instagram.com/publicapi/oembed/?maxwidth=696&maxheight=1000&url=https://www.instagram.com/p/BvmdPLyBFjh/&dnt=1&format=json
Resolving www.instagram.com (www.instagram.com)... 31.13.91.174, 2a03:2880:f21b:e5:face:b00c:0:4420
Connecting to www.instagram.com (www.instagram.com)|31.13.91.174|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://api.instagram.com/oembed/?maxwidth=696&maxheight=1000&url=https://www.instagram.com/p/BvmdPLyBFjh/&dnt=1&format=json [following]
--2019-03-31 16:16:04--  https://api.instagram.com/oembed/?maxwidth=696&maxheight=1000&url=https://www.instagram.com/p/BvmdPLyBFjh/&dnt=1&format=json
Connecting to api.instagram.com (api.instagram.com)|31.13.64.52|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8772 (8.6K) [application/json]
Saving to: ‘oembed?maxwidth=696&maxheight=1000&url=https:%2F%2Fwww.instagram.com%2Fp%2FBvmdPLyBFjh%2F&dnt=1&format=json’

Not sure is it possible to update something in the core to fix redirection.

Or at least

curl_setopt($this->handle, CURLOPT_FOLLOWLOCATION, true);

could be used for embeds, to avoid calling function Requests_Transport::request every time.

#3 @SergeyBiryukov
6 years ago

  • Milestone set to Awaiting Review

#4 @Krstarica
5 years ago

This is related and @biranit found the solution:
https://wordpress.org/support/topic/facebook-video-oembed-not-working/

oEmbed timeout should definitely be higher than default 5 seconds and configurable somewhere.

#5 @Krstarica
5 years ago

After 3 weeks of testing, I confirm that increasing timeout from 5 to 30 seconds using the code below fixed the reported issue:

function my_increase_oembed_timeout($args) {
	$args["timeout"] = 30;
	return $args;
}
add_filter( 'oembed_remote_get_args', 'my_increase_oembed_timeout');

My suggestion is to have oEmbed timeout configurable somewhere and to log timeouts as {{timeout}} instead of pretty vague {{unknown}}

Note: See TracTickets for help on using tickets.