Skip to content
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

Sync failed — using apache server on php v 8.3.6 #22

Open
paubou opened this issue May 2, 2024 · 5 comments
Open

Sync failed — using apache server on php v 8.3.6 #22

paubou opened this issue May 2, 2024 · 5 comments

Comments

@paubou
Copy link

paubou commented May 2, 2024

working locally but as soon as puched to staging or production on apache server, it's not working.

error: sync failed in the admin panel;
K4.2.0
PHP8.3.6

@sylvainjule
Copy link
Owner

sylvainjule commented May 5, 2024

Would need more details about this:

  • Is the local config the same (i.e. PHP 8.3.6)?
  • What happens? Is an error message shown? Does the console log anything?
  • The field makes an API call to fetch the embed data, can you try dumping kirby()->site()->getEmbedData('https://vimeo.com/868805980') anywhere on your website, what does it return?

@paubou paubou changed the title not working using apache server on php v 8.3.6 Sync failed — using apache server on php v 8.3.6 May 5, 2024
@mrflix
Copy link

mrflix commented Jun 6, 2024

I ran into the same issue, both on the production server as well as my local environment. Both running PHP 8.1.

Running kirby()->site()->getEmbedData('https://youtu.be/s2R6bD2trz4?si=9TAkSLNA3e62QeQU') produced an error status response with an empty error message.

I disabled the try {} catch {} in getEmbedData and got this error: Embed\Http\NetworkException (23) with an empty message.

Digging further into embeds CurlDispatcher` class I found out that "23" is an error code that somehow doesn't get resolved to its human message in the process:

An error occurred when writing received data to a local file, or an error was returned to libcurl from a write callback.

CurlDispatcher is providing its own CURLOPT_WRITEFUNCTION that writes to 'php://temp'. I logged the writing and it works. I looked upstream in https://github.com/oscarotero/Embed and found neither an error report nor a newer version where they might have fixed this.

I disabled the error exception and the results look fine so for now as my temporary fix I enhanced CurlDispatcher's exec method with a check to ignore error 23:

if (curl_errno($this->curl) && curl_errno($this->curl) != 23){
    $this->error(curl_error($this->curl), curl_errno($this->curl));
}

@mrflix
Copy link

mrflix commented Jun 6, 2024

I found a cleaner way to ignore the error – embed has a built in way:

In siteMethods.php you can change:

$embed = new Embed\Embed();

To:

use Embed\Http\Crawler;
use Embed\Http\CurlClient;

...


$client = new CurlClient();
$client->setSettings([
    'ignored_errors' => [23]
]);
$embed = new Embed\Embed(new Crawler($client));

@ImaCrea
Copy link

ImaCrea commented Jun 11, 2024

Sync also failed on my side when trying with any Youtube video. Here's what happen when I try with https://www.youtube.com/watch?v=ZXJWO2FQ16c for example :

Capture d’écran 2024-06-11 à 21 04 16

Env info
PHP: 8.3.6
K: 3.10.0.1
Plugin: 1.1.2

Debug

It happens only on the production machine hosted by Uberspace. Not on local env. 🤔 Also, it works with Vimeo link but not with a Youtube link.

Here's what I get when I try <?php dump(kirby()->site()->getEmbedData('https://www.youtube.com/watch?v=ZXJWO2FQ16c')); ?> on hosted server :

Capture d’écran 2024-06-11 à 21 13 13

I'll wait for an update, hopefully this feedback helps. Thanks for such a great plugin 🙏

@bnomei
Copy link

bnomei commented Jul 6, 2024

oscarotero/Embed#538

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants