From 042663d92719dbb1cde0cfaade40e3867751abd9 Mon Sep 17 00:00:00 2001
From: Paul Mehrer
Date: Thu, 19 Nov 2020 10:39:48 +0100
Subject: [PATCH] fix(TB FS) path handling in copyTempfile/copyStream
Change-Id: I325d4bfc0563389ec5d1182752a4c7446217f719
Reviewed-on: http://gerrit.tine20.com/customers/18517
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Paul Mehrer
---
tine20/Tinebase/Export/Report/Abstract.php | 3 ++-
tine20/Tinebase/FileSystem.php | 6 ++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/tine20/Tinebase/Export/Report/Abstract.php b/tine20/Tinebase/Export/Report/Abstract.php
index cd2dec4b049..d08fbae5990 100644
--- a/tine20/Tinebase/Export/Report/Abstract.php
+++ b/tine20/Tinebase/Export/Report/Abstract.php
@@ -120,7 +120,8 @@ protected function _saveToFilemanager($generatedExport)
$tempFile = Tinebase_TempFile::getInstance()->createTempFile($exportFilename);
$nodePath = Tinebase_Model_Tree_Node_Path::createFromRealPath($this->_fileLocation->fm_path,
Tinebase_Application::getInstance()->getApplicationByName('Filemanager'));
- Tinebase_FileSystem::getInstance()->copyTempfile($tempFile, $nodePath->statpath . '/' . $index . '_' . $filename);
+ $targetPath = $nodePath->statpath . '/' . $index . '_' . $filename;
+ Tinebase_FileSystem::getInstance()->copyTempfile($tempFile, $targetPath);
}
}
diff --git a/tine20/Tinebase/FileSystem.php b/tine20/Tinebase/FileSystem.php
index e262029bb21..054263025a2 100644
--- a/tine20/Tinebase/FileSystem.php
+++ b/tine20/Tinebase/FileSystem.php
@@ -2843,7 +2843,7 @@ public function clearDeletedFilesFromDatabase($dryRun = true)
* @return Tinebase_Model_Tree_Node
* @throws Tinebase_Exception_AccessDenied
*/
- public function copyTempfile($tempFile, $path, $deleteTempFileAfterCopy = false)
+ public function copyTempfile($tempFile, &$path, $deleteTempFileAfterCopy = false)
{
if ($tempFile === null) {
$tempStream = fopen('php://memory', 'r');
@@ -2900,7 +2900,7 @@ public function setAclFromParent($path, $ifNotNull = false)
* @throws Tinebase_Exception_AccessDenied
* @throws Tinebase_Exception_UnexpectedValue
*/
- public function copyStream($in, $path)
+ public function copyStream($in, &$path)
{
$deleteFile = !$this->fileExists($path);
try {
@@ -2908,6 +2908,8 @@ public function copyStream($in, $path)
throw new Tinebase_Exception_AccessDenied('Permission denied to create file (filename ' . $path . ')');
}
+ $path = stream_context_get_options($handle)['tine20']['path'];
+
if (!is_resource($in)) {
throw new Tinebase_Exception_UnexpectedValue('source needs to be of type stream');
}