From 397f959f18b7d7249e88b8baaec15d53f2d800d0 Mon Sep 17 00:00:00 2001 From: Sander Drenth Date: Tue, 31 May 2022 15:14:54 +0200 Subject: [PATCH] Update uploadObjectsToContainer method Update uploadObjectsToContainer so the files array passed to the OnFileManagerUpload event includes an up-to-date version of $objects. So if a file name has been renamed, $objects passed to the OnFileManagerUpload also reflects these changes. --- core/src/Revolution/Sources/modMediaSource.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/Revolution/Sources/modMediaSource.php b/core/src/Revolution/Sources/modMediaSource.php index fa824a9407e..2216d31f2de 100644 --- a/core/src/Revolution/Sources/modMediaSource.php +++ b/core/src/Revolution/Sources/modMediaSource.php @@ -1108,7 +1108,7 @@ public function uploadObjectsToContainer($container, array $objects = []) $this->xpdo->context->prepare(); $maxFileSize = $this->xpdo->getOption('upload_maxsize', null, 1048576); - foreach ($objects as $file) { + foreach ($objects as $key => $file) { $this->xpdo->invokeEvent('OnFileManagerBeforeUpload', [ 'files' => &$objects, 'file' => &$file, @@ -1170,6 +1170,8 @@ public function uploadObjectsToContainer($container, array $objects = []) $this->xpdo->log(modX::LOG_LEVEL_ERROR, $e->getMessage()); } } + + $objects[$key] = $file; } $this->xpdo->invokeEvent('OnFileManagerUpload', [