Fix a bug when syncing international characters in files by robinsowell · Pull Request #5218 · ExpressionEngine/ExpressionEngine · GitHub
Skip to content

Fix a bug when syncing international characters in files#5218

Open
robinsowell wants to merge 1 commit into
7.devfrom
bugfix/improve-file-sync-error-handling
Open

Fix a bug when syncing international characters in files#5218
robinsowell wants to merge 1 commit into
7.devfrom
bugfix/improve-file-sync-error-handling

Conversation

@robinsowell

Copy link
Copy Markdown
Contributor

Had an issue syncing with a file with ö in the name. Sync would appear to never finish, though the file did end up in the upload directory. Same file could be uploaded fine.

Looks like there are a few differences in unicode character handling- namely getDirectoryMap() → Flysystem Local adapter + getWithMetadata() + basename() on macOS (darwin) can return decomposed Unicode (NFD) while PHP/DB/Flysystem normalization elsewhere uses composed (NFC). Comparisons like $fileInfo['path'] != $clean_filename or getFileByPath() DB lookups can behave unexpectedly.

This fix does a few things:

  • Stray d in sync JS throws ReferenceError on the “undefined errors” branch and can break the sync flow
  • doSyncFiles() returning false in a few early cases rather than json
  • flattenDirectoryMap() assigning recursive return (null) - bigger change, but I think it's solid. Wasn't critical to the issue at hand, but now can recurse without overwrite; keep parent paths for non‑empty dirs so subfolders still sync in a sane order

@TomJaeger

Copy link
Copy Markdown
Contributor

@TomJaeger TomJaeger added this to the 7.5.22 milestone Apr 20, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 152d0de6eb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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 👍 / 👎.

@TomJaeger TomJaeger modified the milestones: 7.5.22, 7.5.x Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants