From 084eb293681bd25cfe84d38faf2d7999abc7cc51 Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Thu, 23 Jul 2026 14:52:43 +0200 Subject: [PATCH 1/3] Refactor VideoSerializationHandler for asset properties Refactored video asset serialization to use private methods for duration, width, and height retrieval with error handling. --- .../VideoSerializationHandler.php | 54 +++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/src/Service/Serializer/AssetTypeSerializationHandler/VideoSerializationHandler.php b/src/Service/Serializer/AssetTypeSerializationHandler/VideoSerializationHandler.php index e7b748098..404842cc5 100644 --- a/src/Service/Serializer/AssetTypeSerializationHandler/VideoSerializationHandler.php +++ b/src/Service/Serializer/AssetTypeSerializationHandler/VideoSerializationHandler.php @@ -37,9 +37,9 @@ public function getAdditionalSystemFields(Asset $asset): array return [ VideoSystemField::IMAGE_THUMBNAIL->value => $this->getImageThumbnail($asset), - VideoSystemField::DURATION->value => $asset->getDuration(), - VideoSystemField::WIDTH->value => $asset->getWidth(), - VideoSystemField::HEIGHT->value => $asset->getHeight(), + VideoSystemField::DURATION->value => $this->getDuration($asset), + VideoSystemField::WIDTH->value => $this->getWidth($asset), + VideoSystemField::HEIGHT->value => $this->getHeight($asset), ]; } @@ -66,4 +66,52 @@ private function getImageThumbnail(Video $video): ?string return null; } + + private function getDuration(Video $asset): ?int + { + try { + return $asset->getDuration(); + } + catch (Exception $e) { + $this->logger->error('Failed getting duration for video asset: ' . + $video->getId() . + ' error ' . + $e->getMessage() + ); + } + + return null; + } + + private function getWidth(Video $asset): ?int + { + try { + return $asset->getWidth(); + } + catch (Exception $e) { + $this->logger->error('Failed getting width for video asset: ' . + $video->getId() . + ' error ' . + $e->getMessage() + ); + } + + return null; + } + + private function getHeight(Video $asset): ?int + { + try { + return $asset->getHeight(); + } + catch (Exception $e) { + $this->logger->error('Failed getting height for video asset: ' . + $video->getId() . + ' error ' . + $e->getMessage() + ); + } + + return null; + } } From 001d051a6208dc972459a5750a4fc08df5940e40 Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Thu, 23 Jul 2026 14:57:56 +0200 Subject: [PATCH 2/3] Fix error logging in VideoSerializationHandler Updated error logging to use asset ID instead of video ID for consistency. --- .../VideoSerializationHandler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Service/Serializer/AssetTypeSerializationHandler/VideoSerializationHandler.php b/src/Service/Serializer/AssetTypeSerializationHandler/VideoSerializationHandler.php index 404842cc5..da7a5ff65 100644 --- a/src/Service/Serializer/AssetTypeSerializationHandler/VideoSerializationHandler.php +++ b/src/Service/Serializer/AssetTypeSerializationHandler/VideoSerializationHandler.php @@ -74,7 +74,7 @@ private function getDuration(Video $asset): ?int } catch (Exception $e) { $this->logger->error('Failed getting duration for video asset: ' . - $video->getId() . + $asset->getId() . ' error ' . $e->getMessage() ); @@ -90,7 +90,7 @@ private function getWidth(Video $asset): ?int } catch (Exception $e) { $this->logger->error('Failed getting width for video asset: ' . - $video->getId() . + $asset->getId() . ' error ' . $e->getMessage() ); @@ -106,7 +106,7 @@ private function getHeight(Video $asset): ?int } catch (Exception $e) { $this->logger->error('Failed getting height for video asset: ' . - $video->getId() . + $asset->getId() . ' error ' . $e->getMessage() ); From 674779f402ce9b12e7c01f5c8dac1ef290df6475 Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Thu, 23 Jul 2026 15:08:12 +0200 Subject: [PATCH 3/3] Update VideoSerializationHandler.php --- .../VideoSerializationHandler.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Service/Serializer/AssetTypeSerializationHandler/VideoSerializationHandler.php b/src/Service/Serializer/AssetTypeSerializationHandler/VideoSerializationHandler.php index da7a5ff65..6d74836cd 100644 --- a/src/Service/Serializer/AssetTypeSerializationHandler/VideoSerializationHandler.php +++ b/src/Service/Serializer/AssetTypeSerializationHandler/VideoSerializationHandler.php @@ -26,6 +26,8 @@ class VideoSerializationHandler extends AbstractHandler { use LoggerAwareTrait; + private const ERROR_SEPARATOR = ' error '; + /** * @throws Exception */ @@ -59,7 +61,7 @@ private function getImageThumbnail(Video $video): ?string } catch (Exception $e) { $this->logger->error('Thumbnail generation failed for video asset: ' . $video->getId() . - ' error ' . + self::ERROR_SEPARATOR . $e->getMessage() ); } @@ -71,11 +73,10 @@ private function getDuration(Video $asset): ?int { try { return $asset->getDuration(); - } - catch (Exception $e) { + } catch (Exception $e) { $this->logger->error('Failed getting duration for video asset: ' . $asset->getId() . - ' error ' . + self::ERROR_SEPARATOR . $e->getMessage() ); } @@ -87,11 +88,10 @@ private function getWidth(Video $asset): ?int { try { return $asset->getWidth(); - } - catch (Exception $e) { + } catch (Exception $e) { $this->logger->error('Failed getting width for video asset: ' . $asset->getId() . - ' error ' . + self::ERROR_SEPARATOR . $e->getMessage() ); } @@ -103,11 +103,10 @@ private function getHeight(Video $asset): ?int { try { return $asset->getHeight(); - } - catch (Exception $e) { + } catch (Exception $e) { $this->logger->error('Failed getting height for video asset: ' . $asset->getId() . - ' error ' . + self::ERROR_SEPARATOR . $e->getMessage() ); }