You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to install the server plugin via Composer as a mu-plugin. I'm doing that by modifying the installer path for the server plugin in my composer.json, like so:
This results in a server plugin PHP file installed inside a subdirectory of the mu-plugins folder located at mu-plugins/wp-cli-login-server/wp-cli-login-server.php.
However, the command only checks for the mu-plugin PHP file at mu-plugins/wp-cli-login-server.php.
Since the command is unable to locate that file, it assumes that the plugin is installed as a normal plugin. So when you attempt to execute a command like wp login as 1, the command fails and you get an error like file_get_contents(/path/to/plugins/wp-cli-login-server/wp-cli-login-server.php): Failed to open stream: No such file or directory
This error happens instead of a message that the server plugin isn't installed because the command doesn't test for the location of the server plugin, but rather the existence of the WP_CLI_Login\WP_CLI_Login_Server class.
Alter the mustUse() function above to look for the server plugin in both mu-plugins/wp-cli-login-server.php and mu-plugins/wp-cli-login-server/wp-cli-login-server.php
Instead of using constants to define the potential locations of the server plugin, use Reflection to get the location of the server plugin. E.g. (new \ReflectionClass(WP_CLI_Login_Server::class))->getFileName(). IMO this approach is more flexible and better aligns with the isActive() test linked above
Happy to submit a PR if this makes sense
The text was updated successfully, but these errors were encountered:
Problem
I'd like to install the server plugin via Composer as a mu-plugin. I'm doing that by modifying the installer path for the server plugin in my
composer.json
, like so:This results in a server plugin PHP file installed inside a subdirectory of the
mu-plugins
folder located atmu-plugins/wp-cli-login-server/wp-cli-login-server.php
.However, the command only checks for the mu-plugin PHP file at
mu-plugins/wp-cli-login-server.php
.wp-cli-login-command/src/ServerPlugin.php
Lines 60 to 63 in ab20aee
Since the command is unable to locate that file, it assumes that the plugin is installed as a normal plugin. So when you attempt to execute a command like
wp login as 1
, the command fails and you get an error likefile_get_contents(/path/to/plugins/wp-cli-login-server/wp-cli-login-server.php): Failed to open stream: No such file or directory
This error happens instead of a message that the server plugin isn't installed because the command doesn't test for the location of the server plugin, but rather the existence of the
WP_CLI_Login\WP_CLI_Login_Server
class.wp-cli-login-command/src/ServerPlugin.php
Lines 36 to 39 in ab20aee
Potential fixes
mustUse()
function above to look for the server plugin in bothmu-plugins/wp-cli-login-server.php
andmu-plugins/wp-cli-login-server/wp-cli-login-server.php
(new \ReflectionClass(WP_CLI_Login_Server::class))->getFileName()
. IMO this approach is more flexible and better aligns with theisActive()
test linked aboveHappy to submit a PR if this makes sense
The text was updated successfully, but these errors were encountered: