[BUGFIX] Catch Exception while extracting metadata 08/54708/2
authorrickymk <ricky.mk@pitsolutions.com>
Tue, 29 Aug 2017 11:18:10 +0000 (16:48 +0530)
committerWouter Wolters <typo3@wouterwolters.nl>
Mon, 27 Nov 2017 22:37:03 +0000 (23:37 +0100)
Catch InsufficientFileAccessPermissionsException while extracting
metadata. Reason for this exception could be that the file extension is
not allowed by the ['BE']['fileDenyPattern'] setting.

This patch makes sure that the indexer doesn't break and is able to
extract the other files from storage.

Resolves: #82060
Release: master, 8.7, 7.6
Change-Id: I37950aa70f4f59b388c6b9203e1922708ad07b71
Reviewed-on: https://review.typo3.org/54708
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Classes/Resource/Index/Indexer.php

index 2813fdd..25d69d4 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Resource\Index;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException;
+use TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Resource\ResourceStorage;
@@ -108,10 +110,15 @@ class Indexer
             $fileObject = $this->getResourceFactory()->getFileObject($indexRecord['uid'], $indexRecord);
             // Check for existence of file before extraction
             if ($fileObject->exists()) {
-                $this->extractMetaData($fileObject);
-
-                // Mark file as missing and continue with next record
+                try {
+                    $this->extractMetaData($fileObject);
+                } catch (InsufficientFileAccessPermissionsException $e) {
+                    //  We skip files that are not accessible
+                } catch (IllegalFileExtensionException $e) {
+                    //  We skip files that have an extension that we don't allow
+                }
             } else {
+                // Mark file as missing and continue with next record
                 $this->getFileIndexRepository()->markFileAsMissing($indexRecord['uid']);
             }
         }