Skip to content

Commit

Permalink
[TASK] Add hook to upload methods in GeneralUtility
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
NeoBlack authored and andreaskienast committed Apr 6, 2018
1 parent 3826c61 commit b01ef29
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions typo3/sysext/core/Classes/Utility/GeneralUtility.php
Expand Up @@ -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
Expand Down Expand Up @@ -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 : '';
}
Expand Down

0 comments on commit b01ef29

Please sign in to comment.