Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packages cannot override bundled commands in Phar anymore #4987

Closed
schlessera opened this issue Oct 30, 2018 · 2 comments
Closed

Packages cannot override bundled commands in Phar anymore #4987

schlessera opened this issue Oct 30, 2018 · 2 comments

Comments

@schlessera
Copy link
Member

WP-CLI v2 introduced a regression that the test suite didn't catch: commands that are bundled cannot be overridden anymore by installing them through the package manager.

The main issue is that when the Phar is being assembled, the bundle autoloader and the framework autoloader are combined, and the timing for loading that combined autoloader is adapted for the framework, not the bundled commands.

We previously needed kind of a hack to achieve this overriding, by splitting up the autoloader through a Composer plugin.

While splitting up the packages into two separate ones (one for the framework and one for the bundle) solved this for a Composer stack, the problem still remains for the Phar file ... only that we've since removed the hack to make it work.

@schlessera
Copy link
Member Author

To get rid of these issues once and for all, I'll decouple the autoloading from the framework (which we want to control) from the autoloading done through Composer (which we don't always control).

We already have an autoloader included for the bootstrapping steps, so it's just a matter of replacing the PSR-4 entry in composer.json for the framework with a call to that custom autoloader.

@schlessera
Copy link
Member Author

I found out why the existing tests did not detect this problem. To keep the dependencies for the tests in check, the bootstrap tests only ever tried to override the cli version command.

The cli * commands are part of the commands directly included with the framework, and are pulled in via the RegisterFrameworkCommands bootstrap step.

A --debug output shows that these are the only ones that don't get mixed into the regular Composer commands, so they are actually the only ones that still work as intended:

Debug (bootstrap): Framework autoloader paths: /Users/alain/dev/newcli/wp-cli/vendor/autoload.php (0.058s)
Debug (bootstrap): Loading detected autoloader: /Users/alain/dev/newcli/wp-cli/vendor/autoload.php (0.058s)
Debug (commands): Adding command: db (0.058s)
Debug (commands): Adding command: comment (0.058s)
Debug (commands): Adding command: meta in comment Namespace (0.058s)
Debug (commands): Adding command: menu (0.058s)
Debug (commands): Adding command: item in menu Namespace (0.058s)
Debug (commands): Adding command: location in menu Namespace (0.058s)
Debug (commands): Deferring command: network meta (0.058s)
Debug (commands): Adding command: option (0.058s)
Debug (commands): Adding command: post (0.058s)
Debug (commands): Adding command: meta in post Namespace (0.058s)
Debug (commands): Adding command: term in post Namespace (0.058s)
Debug (commands): Adding command: post-type (0.058s)
Debug (commands): Adding command: site (0.058s)
Debug (commands): Adding command: meta in site Namespace (0.058s)
Debug (commands): Adding command: option in site Namespace (0.058s)
Debug (commands): Adding command: taxonomy (0.058s)
Debug (commands): Adding command: term (0.058s)
Debug (commands): Adding command: meta in term Namespace (0.058s)
Debug (commands): Adding command: user (0.058s)
Debug (commands): Adding command: meta in user Namespace (0.058s)
Debug (commands): Adding command: session in user Namespace (0.058s)
Debug (commands): Adding command: term in user Namespace (0.058s)
Debug (commands): Adding command: network (0.058s)
Debug (hooks): Processing hook "after_add_command:network" with 1 callbacks (0.058s)
Debug (hooks): On hook "after_add_command:network": Closure in file /Users/alain/dev/newcli/wp-cli/php/class-wp-cli.php at line 624 (0.059s)
Debug (commands): Adding command: meta in network Namespace (0.059s)
Debug (commands): Adding command: plugin (0.059s)
Debug (commands): Adding command: theme (0.059s)
Debug (commands): Adding command: mod in theme Namespace (0.059s)
Debug (commands): Adding command: eval (0.059s)
Debug (commands): Adding command: eval-file (0.059s)
Debug (commands): Adding command: core (0.059s)
Debug (commands): Adding command: config (0.059s)
Debug (commands): Adding command: package (0.059s)
Debug (bootstrap): Loading packages from: /Users/alain/.wp-cli/packages/vendor/autoload.php (0.059s)
Debug (bootstrap): Loading detected autoloader: /Users/alain/.wp-cli/packages/vendor/autoload.php (0.059s)
Debug (commands): Adding command: scaffold (0.064s)
Debug (commands): Adding command: admin (0.064s)
Debug (commands): Adding command: package in scaffold Namespace (0.067s)
Debug (commands): Adding command: package-readme in scaffold Namespace (0.067s)
Debug (commands): Adding command: package-tests in scaffold Namespace (0.067s)
Debug (commands): Adding command: package-github in scaffold Namespace (0.067s)
Debug (bootstrap): Adding framework command: /Users/alain/dev/newcli/wp-cli/php/commands/cli.php (0.068s)
Debug (commands): Adding command: cli (0.069s)
Debug (commands): Adding command: cache in cli Namespace (0.069s)
Debug (bootstrap): Adding framework command: /Users/alain/dev/newcli/wp-cli/php/commands/help.php (0.069s)
Debug (commands): Adding command: help (0.07s)
Debug (bootstrap): Fallback autoloader paths: /Users/alain/dev/newcli/wp-cli/vendor/autoload.php (0.071s)
Debug (bootstrap): Loading detected autoloader: /Users/alain/dev/newcli/wp-cli/vendor/autoload.php (0.071s)
Debug (bootstrap): Using default global config: /Users/alain/.wp-cli/config.yml (0.071s)
Debug (bootstrap): No project config found (0.071s)
Debug (bootstrap): argv: /Users/alain/dev/newcli/wp-cli/bin/../php/boot-fs.php cli version --debug (0.071s)
Debug (bootstrap): ABSPATH defined: / (0.071s)
Debug (hooks): Processing hook "before_run_command" with 1 callbacks (0.071s)
Debug (hooks): On hook "before_run_command": WP_CLI\Bootstrap\RegisterDeferredCommands->add_deferred_commands() (0.071s)
Debug (bootstrap): Running command: cli version (0.071s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant