Repository navigation
🐛 fix(bones): deploy creates a missing destination parent and fails when a copy fails - #143
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A critical path-resolution flaw allows a crafted destination to bypass the safety guard and write into the source plugin, while tests do not cover nested-copy failure propagation or partial ZIP-directory cleanup.
1 open issue
What changed in this PR
This PR addresses #139 by making the WPBones deploy command create missing destination parents and report copy failures instead of falsely reporting success.
Changes:
- Creates destination directories recursively and propagates write failures while treating intentional skips as successful.
- Exits with a failure message and removes ZIP staging files when copying fails.
- Adds process tests for missing parents, skipped files, unwritable destinations, and safety refusals.
| File | Description |
|---|---|
tests/Console/DeployDestinationTest.php |
Adds destination creation, failure, and safety regression tests. |
src/Console/bin/bones |
Adds recursive directory creation, copy-failure tracking, and deploy failure handling. |
Review effort: Balanced
gfazioli
added a commit
that referenced
this pull request
Nov 23, 2026
…leteDirectory without glob Missing parents are created one by one from the top, since mkdir()'s recursive flag collapses link/.. lexically while the destination guard resolves the link first. deleteDirectory() no longer builds a glob() pattern from the path (a [ab] in the name matched sibling folders) and never follows a symlinked folder. The progress check mark waits for the copy's result.
…hen a copy fails xcopy() made the destination with a non-recursive mkdir and dropped every result, so a destination whose parent did not exist printed 'Deploy completed!' with exit 0 and nothing copied. It now creates the parents like mkdir -p (after assertSafeDeployDestination(), which still runs first) and returns false only when a write fails, not for a file skipped on purpose; deploy() exits 1 on it.
…leteDirectory without glob Missing parents are created one by one from the top, since mkdir()'s recursive flag collapses link/.. lexically while the destination guard resolves the link first. deleteDirectory() no longer builds a glob() pattern from the path (a [ab] in the name matched sibling folders) and never follows a symlinked folder. The progress check mark waits for the copy's result.
gfazioli
force-pushed
the
fix/deploy-missing-parent
branch
from
November 23, 2026 10:43
be106d1 to
bd83f6d
Compare
…nd no staging folder
…issing folder, stop the parent walk at the root
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.

What was wrong
xcopy()made the destination with a non-recursive, uncheckedmkdir(), and nothing propagated the result of a copy: the recursion dropped each call's return, the directory branch returnedtrueregardless, anddeploy()ignored the top-level result. With a destination whose parent did not exist (bones deploy /tmp/missing-parent/my-plugin) everymkdir/copyfailed, and the deploy still printedDeploy completed!and exited 0.xcopy()also returnedfalsefor a file skipped on purpose, sofalsemeant both "skipped" and "failed".What changed
mkdir -p.assertSafeDeployDestination()still runs first (before the build and before anything is created), so a refused destination creates no folders.xcopy()returnsfalseonly when a write fails (mkdir,copy,symlink); a dotfile or skip-list entry returnstrue. It stops at the first failure and records the path.deploy()ends withDeploy failed: could not write '<path>'. The destination is incomplete.and exit status 1 (the-tmpfolder of--create-zipis removed first). The PHP warnings are suppressed in favour of that one message.mkdir(), notmkdir()'s recursive flag: PHP collapseslink/..lexically while the guard resolves the link first, so a destination could be approved for one place and created in another.assertAutoloadedFilesShipped()is left as it is: the empty deploy it could not see is now unreachable, because a failed copy exits before it runs.After review (Codex round 1)
deleteDirectory()no longer usesglob()(a[ab]in the destination name matched sibling foldersxa/xband emptied them; pre-existing) and never follows a symlinked folder inside an old destination.--create-zipcleanup runs only if the staging folder exists...destination lands where the OS resolves it, a refused one behind a symlink creates nothing, glob characters in the destination, a symlinked folder inside the old destination survives the replace, a nested copy failure exits 1 naming the file. The symlink, glob and symlinked-folder ones fail on the previous commit's code; the nested-failure one already passed there and guards the first commit.Fixes #139
Tests
tests/Console/DeployDestinationTest.php(process tests): missing parents are created, a file skipped on purpose is not a failure, a parent that is a regular file fails, a read-only parent fails, a refused destination (inside the plugin,contains the plugin) creates nothing. Red on the unfixed code: 3 of the first 5 fail (missing parents, regular-file parent, read-only parent); the other two pass there by design (they guard against regressions of the fix).composer test: 368 tests before, 378 tests / 1062 assertions after, all green (the 3 deprecations are pre-existing).Live, in WPKirk-Developing
.claude/scripts/deploy-missing-parent-live-smoke.sh(workspace tooling, not in this repo) deploys the bench to a path whose parent is missing, to a path under a regular file, and under a read-only folder, and checksdebug.log.v3.3.0 (red):
This branch (green):
Review rounds
mkdir()'s recursive flag collapsedlink/..lexically while the guard followed the link;deleteDirectory()read the path as aglob()pattern (a destination namedx[ab]emptiedxa/andxb/) and followed a symlinked folder into its target; no nested-failure test; the copy step's check mark printed before the failure. Fixed in bd83f6d: parents are made onemkdir()at a time from the top down,deleteDirectory()walksscandir()and unlinks links. Copilot asked for the nested failure with--create-ziptoo: b0b1134..or..after a MISSING folder resolves through a link the guard never followed once that folder exists; the parent walk had no stop at the root. Fixed in bf65cf0: the walk refuses a./..in the missing tail before anymkdir()(deploy ../deploy-versionfrom the plugin still works, tested) and stops whendirname()stops changing.resolvePath()splits on it), and a plugin path typed with different capitalization on a case-insensitive volume.composer testat bf65cf0, rebased on master with #144: 386 tests / 1083 assertions, green. Live smoke green on bf65cf0.