sylvainjule / kirby-embed

Embed field for Kirby 3 and 4.
74 stars 3 forks source link

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

Open paubou opened 4 months ago

paubou commented 4 months ago

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 commented 4 months ago

Would need more details about this:

mrflix commented 3 months ago

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 embedsCurlDispatcher` 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 commented 3 months ago

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 commented 3 months ago

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 commented 2 months ago

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