getgrav / grav-plugin-login

Grav Login Plugin
http://getgrav.org
MIT License
44 stars 54 forks source link

CLI does not work anymore after 3.5.0 #280

Closed gramakri closed 2 years ago

gramakri commented 2 years ago

I am trying to update the GravCMS Cloudron package to the latest release 1.7.19. With recent releases of the admin plugin, I found that bin/plugin login new-user does not work anymore. It fails with Identifier "login" is not defined.

# /app/code/bin/plugin login new-user
In Container.php line 101:                                     
  Identifier "login" is not defined.  

Digging deeper, I found that the CLI is having trouble loading the login plugin. As you can see below, the login plugin is not even listed anymore.

# /app/code/bin/plugin 

Usage:
  /app/code/bin/plugin [slug] [command] [arguments]

Example:
  /app/code/bin/plugin error log -l 1 --trace

Plugins with CLI available:
  01. email           /app/code/bin/plugin email list
  02. error           /app/code/bin/plugin error list
  03. flex-objects    /app/code/bin/plugin flex-objects list
  04. problems        /app/code/bin/plugin problems list

Digging even deeper, I logged the exception in Plugins.php::all() :

Pimple\Exception\UnknownIdentifierException: Identifier "login" is not defined. in /app/code/vendor/pimple/pimple/src/Pimple/Container.php:101
Stack trace:
#0 /app/code/user/plugins/login/login.php(1144): Pimple\Container->offsetGet()
#1 /app/code/system/src/Grav/Common/Data/Blueprint.php(445): Grav\Plugin\LoginPlugin::defaultRedirectAfterLogin()
#2 /app/code/system/src/Grav/Common/Data/Blueprint.php(178): Grav\Common\Data\Blueprint->dynamicData()
#3 /app/code/system/src/Grav/Common/Data/Blueprints.php(111): Grav\Common\Data\Blueprint->init()
#4 /app/code/system/src/Grav/Common/Data/Blueprints.php(50): Grav\Common\Data\Blueprints->loadFile()
#5 /app/code/system/src/Grav/Common/Plugins.php(262): Grav\Common\Data\Blueprints->get()
#6 /app/code/system/src/Grav/Common/Plugins.php(232): Grav\Common\Plugins::get()
#7 /app/code/system/src/Grav/Console/Plugin/PluginListCommand.php(50): Grav\Common\Plugins::all()
#8 /app/code/system/src/Grav/Console/ConsoleCommand.php(33): Grav\Console\Plugin\PluginListCommand->serve()
#9 /app/code/vendor/symfony/console/Command/Command.php(255): Grav\Console\ConsoleCommand->execute()
#10 /app/code/vendor/symfony/console/Application.php(1009): Symfony\Component\Console\Command\Command->run()
#11 /app/code/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand()
#12 /app/code/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
#13 /app/code/system/src/Grav/Console/Application/PluginApplication.php(80): Symfony\Component\Console\Application->run()
#14 /app/code/bin/plugin(51): Grav\Console\Application\PluginApplication->run()
#15 {main}
gramakri commented 2 years ago

I think the issue started happening after https://github.com/getgrav/grav-plugin-login/commit/05e7003faf7ea8547295d51bea597ee3c372e9fe

rhukster commented 2 years ago

confirmed, we'll take a look at this.

gramakri commented 2 years ago

If it helps, this is easily reproduced using a vanilla cms installation (using docker) like so:

$ docker run -ti cloudron/base:3.0.0 /bin/bash
root@a1e17735d9cf:/# export VERSION=1.7.20
root@a1e17735d9cf:/# mkdir -p /app/code
root@a1e17735d9cf:/# cd /app/code
root@a1e17735d9cf:/app/code# curl -sL https://github.com/getgrav/grav/archive/${VERSION}.tar.gz | tar -xz --strip-components 1 -f -
root@a1e17735d9cf:/app/code# chown -R www-data:www-data /app/code
root@a1e17735d9cf:/app/code# gosu www-data:www-data composer install --no-dev -o 
root@a1e17735d9cf:/app/code# gosu www-data:www-data bin/grav install
root@a1e17735d9cf:/app/code# gosu www-data:www-data bin/gpm install admin
root@e9620f3a92af:/app/code# gosu www-data:www-data bin/plugin 

Usage:
  bin/plugin [slug] [command] [arguments]

Example:
  bin/plugin error log -l 1 --trace

Plugins with CLI available:
  01. email           bin/plugin email list
  02. error           bin/plugin error list
  03. flex-objects    bin/plugin flex-objects list
  04. problems        bin/plugin problems list

root@e9620f3a92af:/app/code# gosu www-data:www-data bin/plugin login

In Container.php line 101:

  Identifier "login" is not defined.  

If you want the full command output of the above - https://paste.cloudron.io/xucivifapu.rb

mahagr commented 2 years ago

Above commit should fix the issue.

nebulade commented 2 years ago

Thanks for getting onto this so fast. What is the best way to verify the fix for us prior to a plugin release?

I tried looking into a way through gpm direct-install but didn't spot any way.

mahagr commented 2 years ago

You can try the fix by manually copying/modifying the plugin file.

gramakri commented 2 years ago

@mahagr @rhukster Can confirm the fix works. Tested with https://git.cloudron.io/cloudron/grav-app/-/commit/de390a3925b9b9879e0436ee68a8bbafc7001d49