modmore / Gitify

Command line toolkit to make managing a MODX site in git a lot easier.
MIT License
122 stars 55 forks source link

Restore command fails with MODX 3 #395

Closed hugopeek closed 2 years ago

hugopeek commented 2 years ago

Summary

The gitify restore command is throwing a fatal error when used in a MODX 3 project (3.0.0-rc2 in my case).

Step to reproduce

Run the following commands:

gitify modx:install 3.0.0-rc2
gitify init
gitify backup
gitify restore

Observed behavior

The following error is thrown:

Please choose the backup to restore (defaults to option 0): 
  [0] 2022-03-16T043815+0000.sql
 > PHP Fatal error:  Uncaught Error: Call to undefined method Symfony\Component\Console\Question\ChoiceQuestion::getAutocompleterCallback() in /home/hugo/Localhost/dev/gitify/vendor/symfony/console/Helper/QuestionHelper.php:111
Stack trace:
#0 /home/hugo/Localhost/dev/gitify/vendor/symfony/console/Helper/QuestionHelper.php(68): Symfony\Component\Console\Helper\QuestionHelper->doAsk()
#1 /home/hugo/Localhost/dev/gitify/vendor/symfony/console/Helper/QuestionHelper.php(464): Symfony\Component\Console\Helper\QuestionHelper->Symfony\Component\Console\Helper\{closure}()
#2 /home/hugo/Localhost/dev/gitify/vendor/symfony/console/Helper/QuestionHelper.php(71): Symfony\Component\Console\Helper\QuestionHelper->validateAttempts()
#3 /home/hugo/Localhost/dev/gitify/src/Command/RestoreCommand.php(132): Symfony\Component\Console\Helper\QuestionHelper->ask()
#4 /home/hugo/Localhost/dev/gitify/vendor/symfony/console/Command/Command.php(299): modmore\Gitify\Command\RestoreCommand->execute()
#5 /home/hugo/Localhost/dev/gitify/vendor/symfony/console in /home/hugo/Localhost/dev/gitify/vendor/symfony/console/Helper/QuestionHelper.php on line 111

Expected behavior

The restore command runs without issue in a 2.x install.

Environment

Gitify 2.0.0-alpha1 MODX 3.0.0-rc2 Debian 12 MariaDB 10.6.7, PHP 7.4, Nginx 1.18.0

JoshuaLuckers commented 2 years ago

This happens because it's using the ChoiceQuestion class that's shipped with MODX 3.

JoshuaLuckers commented 2 years ago

Gitify loads MODX, it does so by requiring a file: https://github.com/modmore/Gitify/blob/15caf4182fc90499b117d99ec0a11e9c72adb67b/src/Gitify.php#L77

In 3.x this file only exists for BC purposes and will autoload the dependencies that are required for 3.x. https://github.com/modxcms/revolution/blob/a5774ed353d41cb4b0b8bbf15efb00916d438435/core/model/modx/modx.class.php#L24

JoshuaLuckers commented 2 years ago

MODX 3 rc-2 appears to be shipping an older version of symfony/console.

JoshuaLuckers commented 2 years ago

With the latest nightly the backup and restore commands work as expected! @Mark-H I think we can close this issue.

Mark-H commented 2 years ago

Can you confirm this works for you with 3.0.0-pl, @hugopeek?

hugopeek commented 2 years ago

Sorry for the late response. Yes, it's working flawlessly again on 3.0.0 and 3.0.1. Thanks guys!