Skip to content

Accept child-theme zips without explicit directory entries - #72

Open
boo-code wants to merge 1 commit into
PrestaShop:devfrom
boo-code:fix/child-theme-implicit-dirs-40615
Open

Accept child-theme zips without explicit directory entries#72
boo-code wants to merge 1 commit into
PrestaShop:devfrom
boo-code:fix/child-theme-implicit-dirs-40615

Conversation

@boo-code

Copy link
Copy Markdown
Questions Answers
Description? Uploading a customised child theme via Design > Theme & Logo > Advanced customization failed with "The file is not valid." whenever the uploaded .zip did not contain explicit directory entries. AdminPsThemeCustoAdvancedController::processCheckZipFormat() decided the archive was valid only if config appeared as a root-level entry, but it built that root list by keeping entries whose path had a single segment after array_filter(explode('/', name)). A bare directory entry (config/) yields one segment and passes; a file entry (config/theme.yml) yields two and is skipped. Many zip tools (and re-zipping the extracted child theme) omit directory entries entirely, so a structurally correct theme was rejected. The fix inspects the first path segment of every entry, so the config folder is detected whether it is described explicitly (a config/ entry) or only implicitly (through config/... files).
Type? bug fix
BC breaks? no
Deprecations? no
Fixed ticket? Fixes PrestaShop/PrestaShop#40615.
How to test? Create a valid child theme zip whose archive contains no explicit directory entries (e.g. build it programmatically, or cd child && zip -X -r ../child.zip . -x '*/'), with config/theme.yml at the root. Before: uploading it under Advanced customization fails with "The file is not valid." After: it is accepted. A zip that does contain a config/ directory entry keeps working, and a zip wrapped in a single root folder is still normalised by checkZipFile() before this check.

Root cause, reproduced

processCheckZipFormat() reduced to its decision logic, run on two archives with identical files:

implicit dirs  (entries: config/theme.yml, preview.png, assets/css/theme.css)        => current: INVALID   fixed: VALID
explicit dirs  (entries: config/, config/theme.yml, preview.png, assets/, ...)        => current: VALID     fixed: VALID

The only difference between the two is whether the archive carries directory entries — the file layout is the same — yet only the explicit one was accepted. After the fix both are accepted, because the check no longer depends on the presence of directory entries.

Note: the module has no PHPUnit harness, so the behaviour above was verified by exercising the method's logic directly against crafted archives rather than with an added unit test.

@ps-jarvis

Copy link
Copy Markdown

Hello @boo-code!

This is your first pull request on ps_themecusto repository of the PrestaShop project.

Thank you, and welcome to this Open Source community!

@github-project-automation github-project-automation Bot moved this to Ready for review in PR Dashboard Jun 27, 2026
processCheckZipFormat() only recognised the required "config" folder when the
uploaded archive contained an explicit "config/" directory entry: it collected
the root level by keeping entries whose path had a single segment after
array_filter(), which a bare directory entry produces but a file entry such as
"config/theme.yml" never does.

Archives produced by tools that omit directory entries (a very common case when
re-zipping the edited child theme) therefore failed validation with "The file
is not valid." even though their structure was correct. Inspect the first path
segment of every entry instead, so the config folder is detected whether it is
described explicitly or only implicitly through the files it contains.
@boo-code
boo-code force-pushed the fix/child-theme-implicit-dirs-40615 branch from f56e129 to a0b185d Compare July 29, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

Child upload

2 participants