From b01ef29c6681414a7d8872985a42801523328fbb Mon Sep 17 00:00:00 2001 From: Frank Naegler Date: Wed, 4 Apr 2018 11:18:15 +0200 Subject: [PATCH] [TASK] Add hook to upload methods in GeneralUtility Resolves: #84600 Releases: master, 8.7, 7.6 Change-Id: I3f4698e892c98aadb41d3e6ba4f1e974a2ca479d Reviewed-on: https://review.typo3.org/56544 Tested-by: TYPO3com Reviewed-by: Stefan Neufeind Tested-by: Stefan Neufeind Reviewed-by: Andreas Fernandez Tested-by: Andreas Fernandez --- .../core/Classes/Utility/GeneralUtility.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index 6c81c57db913..2a9adf879ba9 100644 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -3228,6 +3228,14 @@ public static function sanitizeLocalUrl($url = '') */ 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 @@ public static function upload_to_tempfile($uploadedFileName) { 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 : ''; }