[TASK] Add hook to upload methods in GeneralUtility 44/56544/4
authorFrank Naegler <frank.naegler@typo3.org>
Wed, 4 Apr 2018 09:18:15 +0000 (11:18 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Fri, 6 Apr 2018 15:02:40 +0000 (17:02 +0200)
Resolves: #84600
Releases: master, 8.7, 7.6
Change-Id: I3f4698e892c98aadb41d3e6ba4f1e974a2ca479d
Reviewed-on: https://review.typo3.org/56544
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/core/Classes/Utility/GeneralUtility.php

index 6c81c57..2a9adf8 100644 (file)
@@ -3228,6 +3228,14 @@ class GeneralUtility
      */
     public static function upload_copy_move($source, $destination)
     {
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Core\Utility\GeneralUtility']['moveUploadedFile'] ?? null)) {
+            $params = ['source' => $source, 'destination' => $destination, 'method' => 'upload_copy_move'];
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Core\Utility\GeneralUtility']['moveUploadedFile'] as $hookMethod) {
+                $fakeThis = false;
+                self::callUserFunction($hookMethod, $params, $fakeThis);
+            }
+        }
+
         $result = false;
         if (is_uploaded_file($source)) {
             // Return the value of move_uploaded_file, and if FALSE the temporary $source is still
@@ -3256,6 +3264,14 @@ class GeneralUtility
     {
         if (is_uploaded_file($uploadedFileName)) {
             $tempFile = self::tempnam('upload_temp_');
+            if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Core\Utility\GeneralUtility']['moveUploadedFile'] ?? null)) {
+                $params = ['source' => $uploadedFileName, 'destination' => $tempFile, 'method' => 'upload_to_tempfile'];
+                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Core\Utility\GeneralUtility']['moveUploadedFile'] as $hookMethod) {
+                    $fakeThis = false;
+                    self::callUserFunction($hookMethod, $params, $fakeThis);
+                }
+            }
+
             move_uploaded_file($uploadedFileName, $tempFile);
             return @is_file($tempFile) ? $tempFile : '';
         }