Skip to content
Snippets Groups Projects
Commit 31bac932 authored by Farbod Zamani's avatar Farbod Zamani
Browse files

Resolves "Redundant duplication of Multi-linked contents during CW copy"

parent c0afe3fb
No related branches found
No related tags found
No related merge requests found
...@@ -302,6 +302,15 @@ abstract class BlockType ...@@ -302,6 +302,15 @@ abstract class BlockType
*/ */
protected function copyFileById(string $fileId, string $rangeId): string protected function copyFileById(string $fileId, string $rangeId): string
{ {
if ($this->block->container->structural_element->range_id === $rangeId) {
return $fileId;
}
static $file_map = [];
if (isset($file_map[$fileId])) {
return $file_map[$fileId];
}
$user = \User::findCurrent(); $user = \User::findCurrent();
if ($file_ref = \FileRef::find($fileId)) { if ($file_ref = \FileRef::find($fileId)) {
$copiedFile = \FileManager::copyFile( $copiedFile = \FileManager::copyFile(
...@@ -310,7 +319,9 @@ abstract class BlockType ...@@ -310,7 +319,9 @@ abstract class BlockType
$user $user
); );
return isset($copiedFile->id) ? $copiedFile->id : ''; if (isset($copiedFile)) {
return $file_map[$fileId] = $copiedFile->id;
}
} }
return ''; return '';
...@@ -326,6 +337,15 @@ abstract class BlockType ...@@ -326,6 +337,15 @@ abstract class BlockType
*/ */
protected function copyFolderById(string $folderId, string $rangeId): string protected function copyFolderById(string $folderId, string $rangeId): string
{ {
if ($this->block->container->structural_element->range_id === $rangeId) {
return $folderId;
}
static $folder_map = [];
if (isset($folder_map[$folderId])) {
return $folder_map[$folderId];
}
$user = \User::findCurrent(); $user = \User::findCurrent();
$destinationFolder = $this->getDestinationFolder($user, $rangeId); $destinationFolder = $this->getDestinationFolder($user, $rangeId);
if ($sourceFolder = \Folder::find($folderId)) { if ($sourceFolder = \Folder::find($folderId)) {
...@@ -335,7 +355,7 @@ abstract class BlockType ...@@ -335,7 +355,7 @@ abstract class BlockType
$user $user
); );
return $copiedFolder->id; return $folder_map[$folderId] = $copiedFolder->id;
} }
return ''; return '';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment