[TASK] Allow multiple extractor services with the same priority 94/59894/8
authorSusanne Moog <susanne.moog@typo3.com>
Thu, 7 Mar 2019 10:23:40 +0000 (11:23 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 23 Aug 2019 15:14:48 +0000 (17:14 +0200)
When having multiple extractor services with the same priority one
gets overwritten by the other. As extensions are free to deliver and
declare extractors, this cannot be fixed on 3rd party level.

ExtractorRegistry has been changed to allow registering multiple
extractors with same priority.

Resolves: #64942
Releases: master
Change-Id: I7581a28739246175e80a2985faf7329ef974669c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/59894
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Tobi Kretschmann <tobi@tobishome.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Tobi Kretschmann <tobi@tobishome.de>
Reviewed-by: Julian Geils <j_geils@web.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/Resource/Index/ExtractorRegistry.php
typo3/sysext/core/Classes/Resource/Service/ExtractorService.php

index 84d7173..4dd637f 100644 (file)
@@ -98,10 +98,9 @@ class ExtractorRegistry implements SingletonInterface
 
         $filteredExtractors = [];
         foreach ($allExtractors as $priority => $extractorObject) {
-            if (empty($extractorObject->getDriverRestrictions())) {
-                $filteredExtractors[$priority] = $extractorObject;
-            } elseif (in_array($driverType, $extractorObject->getDriverRestrictions())) {
-                $filteredExtractors[$priority] = $extractorObject;
+            if (empty($extractorObject->getDriverRestrictions()) ||
+                in_array($driverType, $extractorObject->getDriverRestrictions(), true)) {
+                $filteredExtractors[$extractorObject->getPriority()][] = $extractorObject;
             }
         }
         return $filteredExtractors;
index 166bc14..e13c997 100644 (file)
@@ -39,8 +39,11 @@ class ExtractorService
         $newMetaData = [];
         // Loop through available extractors and fetch metadata for the given file.
         foreach ($this->getExtractionServices($fileObject->getStorage()->getDriverType()) as $service) {
-            if ($this->isFileTypeSupportedByExtractor($fileObject, $service) && $service->canProcess($fileObject)) {
-                $newMetaData[$service->getPriority()] = $service->extractMetaData($fileObject, $newMetaData);
+            foreach ($service ?? [] as $extractorService) {
+                if ($this->isFileTypeSupportedByExtractor($fileObject, $extractorService) &&
+                    $extractorService->canProcess($fileObject)) {
+                    $newMetaData[$extractorService->getPriority()] = $extractorService->extractMetaData($fileObject, $newMetaData);
+                }
             }
         }
         // Sort metadata by priority so that merging happens in order of precedence.