From 9ba85c5a3ce021b58c13d2f330f98db39996371e Mon Sep 17 00:00:00 2001
From: Georgi Mateev <georgi.mateev@sgalinski.de>
Date: Fri, 18 Oct 2024 21:05:23 +0300
Subject: [PATCH] [BUGFIX] Code review fixes

---
 Classes/Service/LicenceCheckService.php |  3 ++-
 Classes/Service/VimeoService.php        | 15 ++++++---------
 README.md                               |  1 +
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/Classes/Service/LicenceCheckService.php b/Classes/Service/LicenceCheckService.php
index 38c7f98..1f29bc7 100644
--- a/Classes/Service/LicenceCheckService.php
+++ b/Classes/Service/LicenceCheckService.php
@@ -127,12 +127,13 @@ class LicenceCheckService {
 	private static $versionToReleaseTimestamp = [
 		'3.0.0' => 1688468637, // Tue, 04 Jul 2023 14:11:50 GMT
 		'4.2.0' => 1717678615, // Tue, 06 Jun 2023 14:57:50 GMT
+		'5.0.0' => 1729271668, // Tue, 18 Oct 2024 20:15:50 GMT+3
 	];
 
 	/**
 	 * The current extension version
 	 */
-	public const CURRENT_VERSION = '4.2.0';
+	public const CURRENT_VERSION = '5.0.0';
 
 	/**
 	 * @param mixed $validUntil A timestamp, which says the lifetime of this key.
diff --git a/Classes/Service/VimeoService.php b/Classes/Service/VimeoService.php
index 129854a..25de782 100644
--- a/Classes/Service/VimeoService.php
+++ b/Classes/Service/VimeoService.php
@@ -184,9 +184,9 @@ class VimeoService implements LoggerAwareInterface {
 	 * @param array|null $response
 	 * @return array|null
 	 */
-	protected function addVideoIdsToResponse(?array $response): ?array {
-		if (!is_array($response)) {
-			return NULL;
+	protected function addVideoIdsToResponse(array $response): array {
+		if (empty($response)) {
+			return [];
 		}
 
 		foreach ($response as $index => $item) {
@@ -222,9 +222,9 @@ class VimeoService implements LoggerAwareInterface {
 	 * @param array|null $response
 	 * @return array|null
 	 */
-	protected function preprocessApiResponse(?array $response): ?array {
-		if (!is_array($response)) {
-			return NULL;
+	protected function preprocessApiResponse(?array $response): array {
+		if (!is_array($response) || $response['status'] >= 400) {
+			return [];
 		}
 
 		// log error & return here, since the response was not OK
@@ -288,7 +288,6 @@ class VimeoService implements LoggerAwareInterface {
 		try {
 			$response = $this->vimeoApiClient->request(self::API_VIDEO . $videoId . '?' . $query);
 		} catch (VimeoRequestException $e) {
-			$response = NULL;
 			throw $e;
 		}
 
@@ -323,7 +322,6 @@ class VimeoService implements LoggerAwareInterface {
 				self::API_CHANNEL . $channelIdentifier . self::API_VIDEO . '?' . $query
 			);
 		} catch (VimeoRequestException $e) {
-			$response = NULL;
 			throw $e;
 		}
 
@@ -360,7 +358,6 @@ class VimeoService implements LoggerAwareInterface {
 				self::API_SHOWCASE . $showcaseId . self::API_VIDEO . '?' . $query
 			);
 		} catch (VimeoRequestException $e) {
-			$response = NULL;
 			throw $e;
 		}
 
diff --git a/README.md b/README.md
index 15d2902..4630f2a 100644
--- a/README.md
+++ b/README.md
@@ -326,6 +326,7 @@ Once it runs it will create the file and we can commit the new version and use i
 1. In the plugin's FlexForm settings, you will see a section for "Filters."
 2. Depending on your site configuration, filters will be available in a select field. You can select the filters you want to display (like search term, video duration, etc.).
 3. Save your settings and publish the page.
+4. IMPORTANT! You must make sure that the user associated with the clientId and clientSecret API keys has the right permissions to search in the channel where the filters are being used. Otherwise searching for a query string will always result in an empty result set.
 
 ---
 
-- 
GitLab