Fix a bug when syncing international characters in files by robinsowell · Pull Request #5218 · ExpressionEngine/ExpressionEngine · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion system/ee/ExpressionEngine/Controller/Files/Uploads.php
10 changes: 6 additions & 4 deletions system/ee/ExpressionEngine/Model/File/UploadDestination.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,13 @@ private function flattenDirectoryMap(&$flatMap = [], $nestedMap = [], $keyPrefix
{
foreach ($nestedMap as $key => $val) {
$flatKey = rtrim($keyPrefix . $key, '/');
if (! isset($flatMap[$flatKey])) {
$flatMap[$flatKey] = $flatKey;
}
if (is_array($val)) {
$flatMap[$flatKey] = $this->flattenDirectoryMap($flatMap, $val, $flatKey . '/');
if ($val !== [] && ! isset($flatMap[$flatKey])) {
$flatMap[$flatKey] = $flatKey;
}
$this->flattenDirectoryMap($flatMap, $val, $flatKey . '/');
Comment on lines +478 to +481

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep empty directories in flattened map

flattenDirectoryMap() now only inserts a directory key when $val !== [], so an empty folder ([]) is dropped entirely. Because getAllFileNames() depends on this flattened list, empty folders are never passed to syncFiles(), which means no Directory model is created for them during sync. This is a behavior regression from the previous implementation and causes folder-only structures to disappear after synchronization.

Useful? React with 👍 / 👎.

} elseif (! isset($flatMap[$flatKey])) {
$flatMap[$flatKey] = $flatKey;
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions themes/ee/asset/javascript/src/cp/files/synchronize.js
Loading