Skip to content
Snippets Groups Projects
Commit 9d497481 authored by Elmar Ludwig's avatar Elmar Ludwig Committed by Jan-Hendrik Willms
Browse files

move declaration to top of function and fix error handling, fixes #336

parent 56f1a4be
No related branches found
No related tags found
No related merge requests found
...@@ -302,11 +302,12 @@ abstract class BlockType ...@@ -302,11 +302,12 @@ abstract class BlockType
*/ */
protected function copyFileById(string $fileId, string $rangeId): string protected function copyFileById(string $fileId, string $rangeId): string
{ {
static $file_map = [];
if ($this->block->container->structural_element->range_id === $rangeId) { if ($this->block->container->structural_element->range_id === $rangeId) {
return $fileId; return $fileId;
} }
static $file_map = [];
if (isset($file_map[$fileId])) { if (isset($file_map[$fileId])) {
return $file_map[$fileId]; return $file_map[$fileId];
} }
...@@ -319,7 +320,7 @@ abstract class BlockType ...@@ -319,7 +320,7 @@ abstract class BlockType
$user $user
); );
if (isset($copiedFile)) { if (is_object($copiedFile)) {
return $file_map[$fileId] = $copiedFile->id; return $file_map[$fileId] = $copiedFile->id;
} }
} }
...@@ -337,11 +338,12 @@ abstract class BlockType ...@@ -337,11 +338,12 @@ abstract class BlockType
*/ */
protected function copyFolderById(string $folderId, string $rangeId): string protected function copyFolderById(string $folderId, string $rangeId): string
{ {
static $folder_map = [];
if ($this->block->container->structural_element->range_id === $rangeId) { if ($this->block->container->structural_element->range_id === $rangeId) {
return $folderId; return $folderId;
} }
static $folder_map = [];
if (isset($folder_map[$folderId])) { if (isset($folder_map[$folderId])) {
return $folder_map[$folderId]; return $folder_map[$folderId];
} }
...@@ -355,7 +357,9 @@ abstract class BlockType ...@@ -355,7 +357,9 @@ abstract class BlockType
$user $user
); );
return $folder_map[$folderId] = $copiedFolder->id; if (is_object($copiedFolder)) {
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