diff --git a/inc/Data/Driver/HttpDriver.php b/inc/Data/Driver/HttpDriver.php index 2e379f27..ff78ec9d 100644 --- a/inc/Data/Driver/HttpDriver.php +++ b/inc/Data/Driver/HttpDriver.php @@ -115,7 +115,7 @@ class HttpDriver { $opt = (\PHP_MAJOR_VERSION >= 8 && \PHP_MINOR_VERSION >= 2) ? \CURLOPT_XFERINFOFUNCTION : \CURLOPT_PROGRESSFUNCTION; \curl_setopt_array($this->inner, [ \CURLOPT_NOPROGRESS => false, - $opt => fn($res, $next_dl, $dl, $next_up, $up) => (int)($dl <= $this->max_file_size), + $opt => fn($res, $next_dl, $dl, $next_up, $up) => (int)($dl > $this->max_file_size), \CURLOPT_FAILONERROR => true, \CURLOPT_FOLLOWLOCATION => false, \CURLOPT_FILE => $fd, diff --git a/inc/Service/Embed/EmbedService.php b/inc/Service/Embed/EmbedService.php index 13d0b650..3f230f0f 100644 --- a/inc/Service/Embed/EmbedService.php +++ b/inc/Service/Embed/EmbedService.php @@ -16,11 +16,20 @@ class EmbedService { private int $thumb_download_timeout; - public function __construct(LogDriver $log, OembedExtractor $oembed_extractor, array $embed_entries, int $thumb_download_timeout) { + public function __construct( + LogDriver $log, + OembedExtractor $oembed_extractor, + HttpDriver $http, + array $embed_entries, + int $thumb_download_timeout, + string $tmp_dir, + ) { $this->log = $log; $this->oembed_extractor = $oembed_extractor; + $this->http = $http; $this->embed_entries = $embed_entries; $this->thumb_download_timeout = $thumb_download_timeout; + $this->tmp_dir = $tmp_dir; } private function make_tmp_file(): string { @@ -104,7 +113,7 @@ class EmbedService { public function getEmbedThumb(string $url, int $entry_index): ?array { $ret = $this->extractThumb($url, $entry_index); list($thumbnail_url, $thumbnail_url_fallback) = $ret; - if (!isset($thumbnail_url, $thumbnail_url_fallback)) { + if (!isset($thumbnail_url)) { return null; } diff --git a/inc/context.php b/inc/context.php index c5375d89..5ec04c50 100644 --- a/inc/context.php +++ b/inc/context.php @@ -94,8 +94,10 @@ function build_context(array $config): Context { return new EmbedService( $c->get(LogDriver::class), $c->get(OembedExtractor::class), + $c->get(HttpDriver::class), $config['embedding_2'], - $config['embed_thumb_timeout'] + $config['embed_thumb_timeout'], + $config['tmp'], ); } ]);