Accept child-theme zips without explicit directory entries - #72
Open
boo-code wants to merge 1 commit into
Open
Conversation
|
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! |
2 tasks
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
force-pushed
the
fix/child-theme-implicit-dirs-40615
branch
from
July 29, 2026 01:42
f56e129 to
a0b185d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
.zipdid not contain explicit directory entries.AdminPsThemeCustoAdvancedController::processCheckZipFormat()decided the archive was valid only ifconfigappeared as a root-level entry, but it built that root list by keeping entries whose path had a single segment afterarray_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 theconfigfolder is detected whether it is described explicitly (aconfig/entry) or only implicitly (throughconfig/...files).cd child && zip -X -r ../child.zip . -x '*/'), withconfig/theme.ymlat the root. Before: uploading it under Advanced customization fails with "The file is not valid." After: it is accepted. A zip that does contain aconfig/directory entry keeps working, and a zip wrapped in a single root folder is still normalised bycheckZipFile()before this check.Root cause, reproduced
processCheckZipFormat()reduced to its decision logic, run on two archives with identical files: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.