kirby-embed icon indicating copy to clipboard operation
kirby-embed copied to clipboard

Sync failed — using apache server on php v 8.3.6

Open paubou opened this issue 1 year ago • 5 comments

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

paubou avatar May 02 '24 17:05 paubou

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?

sylvainjule avatar May 05 '24 09:05 sylvainjule

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 avatar Jun 06 '24 10:06 mrflix

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));

mrflix avatar Jun 06 '24 10:06 mrflix

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 🙏

ImaCrea avatar Jun 11 '24 19:06 ImaCrea

https://github.com/oscarotero/Embed/issues/538

bnomei avatar Jul 06 '24 13:07 bnomei