🐛 fix(bones): skip loadKernel() for rename command on bootstrap#68
Merged
gfazioli merged 2 commits intoApr 18, 2026
Merged
Conversation
After a fresh `composer update` on a plugin whose namespace has been renamed, the `post-autoload-dump` hook ran `php bones rename --update` and fatalled before the rename could execute: Fatal error: Class "Potato\WPBones\Foundation\Console\Kernel" not found in plugin/Console/Kernel.php:7 `boot()` unconditionally called `loadKernel()`, which includes the vendor Kernel (freshly reinstalled as `WPKirk\WPBones\...`) and then the plugin's `plugin/Console/Kernel.php` (referencing the already- renamed `Potato\WPBones\...`). The `use` alias cannot resolve, so the rename command — the very command whose job is to bring the two namespaces back into sync — never gets to run. `boot()`'s docblock already documents the intended behavior: "a special bootstrap in order to avoid the WordPress and kernel environment when we have to rename the plugin and vendor structure." This commit adds the missing guard so `loadKernel()` is skipped when `rename` is present in argv. `$this->kernel` remains null; the only two consumers are already null-guarded. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Keep composer-installed dependencies and JetBrains IDE metadata out of the tree. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
loadKernel()inBonesCommandLine::boot()so it's skipped when the invocation isrename.renameis thebootstrap command that brings vendor and plugin namespaces back into sync; loading the kernel beforehand fatals
because the plugin's
Console\Kernelreferences the renamed vendor namespace while the freshly reinstalled vendorstill ships with the default
WPKirk\WPBones\...prefix.boot(): "a special bootstrap in order to avoid theWordPress and kernel environment when we have to rename the plugin and vendor structure."
vendor/and.idea/to.gitignore.Problem reproduced
On a plugin whose namespace was previously renamed (e.g.
WPKirk→Potato),composer updatehits thepost-autoload-dumphook and fails before the rename can execute:```
Fatal error: Uncaught Error: Class "Potato\WPBones\Foundation\Console\Kernel" not found
in plugin/Console/Kernel.php:7
Script php bones rename --update handling the post-autoload-dump event returned with error code 255
```
Root cause
composer updatereinstallswpbones/wpbonesfresh → vendor namespace resets toWPKirk\WPBones\....post-autoload-dumpcopies the newbonesscript into the plugin root and runsphp bones rename --update.BonesCommandLine::__construct→boot()unconditionally callsloadKernel().loadKernel()includes the vendorFoundation/Console/Kernel.php(namespaceWPKirk\WPBones\...) and then theplugin's
plugin/Console/Kernel.php, which hasuse Potato\WPBones\Foundation\Console\Kernelpersisted from theprior rename.
usealias cannot resolve → fatal atplugin/Console/Kernel.php:7.renamecommand — the exact command whose job is to resync these namespaces — never runs.Chicken-and-egg:
loadKernel()assumes vendor and plugin namespaces already agree, butrename --updateis preciselythe command that makes them agree.
Fix
```php
if (!in_array('rename', $arguments, true)) {
$this->loadKernel();
}
```
$argumentsarray already computed at the top ofboot(). Matchesrename,rename --update, andrename "My Plugin" MyNs.renameis not used as a flag anywhere else, so no false positives.$this->kernelstaysnullon therenamepath. Both downstream consumers (help display, default commanddispatch) are already null-guarded.
renamecommand path changes behavior. Every other command still loads the kernel.Test plan
Potato), deletevendor/wpbones/wpbonesand the plugin's rootbonesfile,then run
composer update—post-autoload-dumpcompletes without fatal;bones rename --updaterewrites vendornamespace to match the plugin and exits 0.
vendor/wpbones/wpbones/src/Foundation/Console/Kernel.phpnow declaresnamespace Potato\WPBones\Foundation\Console;.php bones --helpstill lists custom commands — sanity check that thenon-
renamepath still loads the kernel.php -l src/Console/bin/bones→ no syntax errors.