xwp / wp-cli-ssh

[OBSOLETE] Seamlessly run WP-CLI commands on a remote server via SSH
157 stars 14 forks source link

Play nice with other packages that autoload #11

Closed gMagicScott closed 10 years ago

gMagicScott commented 10 years ago

Since in the composer.json the autoload is set to files, it gets loaded in memory for every time Composer sets up autoload.

When other installed packages require Composer's autoloader, this file get's included. The core of WP-CLI doesn't autoload anything unless the binary is called. The classes WP_CLI_Command and WP_CLI aren't available and leads to a fatal error

PHP Fatal error:  Class 'WP_CLI_Command' not found in [ABSPATH]/vendor/x-team/wp-cli-ssh/wp-cli-ssh.php on line 31

When inside a WP-CLI command, during the bootstrap, it defines 'WP_CLI_ROOT' here or here. By testing for that constant and returning early, the fatal error can be prevented.

westonruter commented 10 years ago

@jonathanbardo please merge once https://github.com/wp-cli/wp-cli/issues/960 is closed.

westonruter commented 10 years ago

Thanks @gMagicScott!