From 9df6cdbf287afa710a03e8409896618138dacf59 Mon Sep 17 00:00:00 2001 From: fowr <89118232+perdedora@users.noreply.github.com> Date: Wed, 2 Apr 2025 09:05:07 -0300 Subject: [PATCH 1/4] EmbedService.php: add missing dependencies --- inc/Service/Embed/EmbedService.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/inc/Service/Embed/EmbedService.php b/inc/Service/Embed/EmbedService.php index 13d0b650..ef305943 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 { From 871e8d78dc4eb4b6c00653c00989888f1cd32ed7 Mon Sep 17 00:00:00 2001 From: fowr <89118232+perdedora@users.noreply.github.com> Date: Wed, 2 Apr 2025 09:05:35 -0300 Subject: [PATCH 2/4] context.php: inject missing dependencies to EmbedService.php --- inc/context.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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'], ); } ]); From a5770a2de575edc96d1ddc6962f026ca480a9de6 Mon Sep 17 00:00:00 2001 From: fowr <89118232+perdedora@users.noreply.github.com> Date: Wed, 2 Apr 2025 09:06:36 -0300 Subject: [PATCH 3/4] EmbedService.php: remove extra check for thumbnail fallback --- inc/Service/Embed/EmbedService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/Service/Embed/EmbedService.php b/inc/Service/Embed/EmbedService.php index ef305943..3f230f0f 100644 --- a/inc/Service/Embed/EmbedService.php +++ b/inc/Service/Embed/EmbedService.php @@ -113,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; } From 9f9fba63d976f45f807aadbfd2d0a96aced315db Mon Sep 17 00:00:00 2001 From: fowr <89118232+perdedora@users.noreply.github.com> Date: Wed, 2 Apr 2025 09:07:56 -0300 Subject: [PATCH 4/4] HttpDriver.php: fix download max size logic --- inc/Data/Driver/HttpDriver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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,