getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony
https://getgrav.org
MIT License
14.59k stars 1.41k forks source link

Bug: Command line plugin aliases no longer functioning #3164

Open jgonyea opened 3 years ago

jgonyea commented 3 years ago

To Reproduce:

From the command line, attempt to use an alias of any command: bin/plugin login newuser

Expected Result:

Command to create a new user is initiated, prompting for a username.

Observed Result:

Command returns an error:

Command "newuser" is not defined.
 Do you want to run "new-user" instead?  (yes/no) [no]:
 >

If I use the full name of the command (bin/plugin login new-user), the command is successful.

Environment:

mahagr commented 3 years ago

It works for some commands: bin/plugin login lookup...

jgonyea commented 3 years ago

In case someone else comes looking at this issue, my current workaround is to use the full name of the command.

jgonyea commented 3 years ago

I think the logic is broken near vendor/symfony/console/Applications.php find($name) function

It doesn't seem to consider aliases properly around L641-L650

mahagr commented 3 years ago

In that case, we need to report this issue to Symfony project. @jgonyea Can you do that as you have already looked into the source code?

jgonyea commented 3 years ago

Submitting an issue to the Symfony project is beyond my skillset, sorry. They're looking for code samples of the bug.

jgonyea commented 1 month ago

Just mentioning this is still broken in v1.8.0-beta.

I wonder if the Grav/Console/Application/CommandLoader/PluginCommandLoader.php could add the aliases in somehow.

jgonyea commented 1 month ago

After poking around, I'm pretty convinced the aforementioned file in Grav is the culprit, as it never checks for aliases before returning a null when searching for the alias.

I'll submit a PR tomorrow or later this weekend.

jgonyea commented 1 month ago

Added PR to address missing aliases.