From 57734b3396e6773f97123239593f4a922edad496 Mon Sep 17 00:00:00 2001
From: Benni Mack <benni@typo3.org>
Date: Sun, 28 Nov 2021 13:26:36 +0100
Subject: [PATCH] [!!!][TASK] Remove FileDumpEIDHook + interface
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The hook has been replaced with the PSR-14 event
"TYPO3\CMS\Core\Resource\Event\ModifyFileDumpEvent"
and is thus removed.

Resolves: #96117
Related: #95080
Releases: master
Change-Id: I0ff076381e1629028a2ca236b23121dfdffdb05c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72337
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Classes/Controller/FileDumpController.php | 23 -----------
 .../Hook/FileDumpEIDHookInterface.php         | 38 -------------------
 ...g-96107-DeprecatedFunctionalityRemoved.rst |  4 +-
 .../Php/ArrayDimensionMatcher.php             |  1 +
 .../ExtensionScanner/Php/ClassNameMatcher.php |  1 +
 5 files changed, 4 insertions(+), 63 deletions(-)
 delete mode 100644 typo3/sysext/core/Classes/Resource/Hook/FileDumpEIDHookInterface.php

diff --git a/typo3/sysext/core/Classes/Controller/FileDumpController.php b/typo3/sysext/core/Classes/Controller/FileDumpController.php
index be549fec2669..422a15e2e004 100644
--- a/typo3/sysext/core/Classes/Controller/FileDumpController.php
+++ b/typo3/sysext/core/Classes/Controller/FileDumpController.php
@@ -23,11 +23,9 @@ use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
 use TYPO3\CMS\Core\Resource\Event\ModifyFileDumpEvent;
-use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\FileInterface;
 use TYPO3\CMS\Core\Resource\FileReference;
-use TYPO3\CMS\Core\Resource\Hook\FileDumpEIDHookInterface;
 use TYPO3\CMS\Core\Resource\ProcessedFile;
 use TYPO3\CMS\Core\Resource\ProcessedFileRepository;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
@@ -60,7 +58,6 @@ class FileDumpController
      * @return ResponseInterface
      * @throws \InvalidArgumentException
      * @throws \RuntimeException
-     * @throws FileDoesNotExistException
      * @throws \UnexpectedValueException
      */
     public function dumpAction(ServerRequestInterface $request): ResponseInterface
@@ -75,26 +72,6 @@ class FileDumpController
             return $this->responseFactory->createResponse(404);
         }
 
-        if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['FileDumpEID.php']['checkFileAccess'])) {
-            trigger_error(
-                'The hook $TYPO3_CONF_VARS[SC_OPTIONS][FileDumpEID.php][checkFileAccess] is deprecated and will stop working in TYPO3 v12.0. Use the ModifyFileDumpEvent instead.',
-                E_USER_DEPRECATED
-            );
-        }
-
-        // Hook: allow some other process to do some security/access checks. Hook should return 403 response if access is rejected, void otherwise
-        // @deprecated: will be removed in TYPO3 v12.0.
-        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['FileDumpEID.php']['checkFileAccess'] ?? [] as $className) {
-            $hookObject = GeneralUtility::makeInstance($className);
-            if (!$hookObject instanceof FileDumpEIDHookInterface) {
-                throw new \UnexpectedValueException($className . ' must implement interface ' . FileDumpEIDHookInterface::class, 1394442417);
-            }
-            $response = $hookObject->checkFileAccess($file);
-            if ($response instanceof ResponseInterface) {
-                return $response;
-            }
-        }
-
         // Allow some other process to do some security/access checks.
         // Event Listeners should return a 403 response if access is rejected
         $event = new ModifyFileDumpEvent($file, $request);
diff --git a/typo3/sysext/core/Classes/Resource/Hook/FileDumpEIDHookInterface.php b/typo3/sysext/core/Classes/Resource/Hook/FileDumpEIDHookInterface.php
deleted file mode 100644
index 51f9fcb6c86c..000000000000
--- a/typo3/sysext/core/Classes/Resource/Hook/FileDumpEIDHookInterface.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-namespace TYPO3\CMS\Core\Resource\Hook;
-
-use Psr\Http\Message\ResponseInterface;
-use TYPO3\CMS\Core\Resource\ResourceInterface;
-
-/**
- * Interface for FileDumpEID Hook to perform some custom security/access checks
- * when accessing file thought FileDumpEID
- * @deprecated since TYPO3 v11 LTS, will be removed in TYPO3 v12.0. Use the PSR-14-based ModifyFileDumpEvent instead.
- */
-interface FileDumpEIDHookInterface
-{
-    /**
-     * Perform custom security/access when accessing file
-     * Method should issue 403 if access is rejected
-     * or 401 if authentication is required via an authorized HTTP authorization scheme.
-     * A 401 header must be accompanied by a www-authenticate header!
-     *
-     * @param \TYPO3\CMS\Core\Resource\ResourceInterface $file
-     * @return ResponseInterface|null
-     */
-    public function checkFileAccess(ResourceInterface $file);
-}
diff --git a/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst b/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst
index c01c5ada6689..dd060944545c 100644
--- a/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst
+++ b/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst
@@ -18,7 +18,7 @@ The following PHP classes that have previously been marked as deprecated for v11
 
 The following PHP interfaces that have previously been marked as deprecated for v11 and were now removed:
 
-- :php:`\Full\Class\Name`
+- :php:`\TYPO3\CMS\Core\Resource\Hook\FileDumpEIDHookInterface`
 
 The following PHP class aliases that have previously been marked as deprecated for v11 and were now removed:
 
@@ -82,7 +82,7 @@ The following global variables have been removed:
 
 The following hooks have been removed:
 
-- :php:`$GLOBALS['TYPO3_CONF_VARS']['KEY']['subKey']`
+- :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['FileDumpEID.php']['checkFileAccess']`
 
 The following signals have been removed:
 
diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayDimensionMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayDimensionMatcher.php
index 94c4d805db63..4e9d07cf27f8 100644
--- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayDimensionMatcher.php
+++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ArrayDimensionMatcher.php
@@ -510,6 +510,7 @@ return [
     '$GLOBALS[\'TYPO3_CONF_VARS\'][\'SC_OPTIONS\'][\'FileDumpEID.php\'][\'checkFileAccess\']' => [
         'restFiles' => [
             'Deprecation-95080-FileDumpCheckFileAccessHook.rst',
+            'Breaking-96107-DeprecatedFunctionalityRemoved.rst',
         ],
     ],
     '$GLOBALS[\'TYPO3_CONF_VARS\'][\'SC_OPTIONS\'][\'t3lib/class.t3lib_extfilefunc.php\'][\'processData\']' => [
diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php
index d276980fef05..ebfb21741898 100644
--- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php
+++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php
@@ -1799,6 +1799,7 @@ return [
     'TYPO3\CMS\Core\Resource\Hook\FileDumpEIDHookInterface' => [
         'restFiles' => [
             'Deprecation-95080-FileDumpCheckFileAccessHook.rst',
+            'Breaking-96107-DeprecatedFunctionalityRemoved.rst',
         ],
     ],
     'TYPO3\CMS\Core\Utility\File\ExtendedFileUtilityProcessDataHookInterface' => [
-- 
GitLab