Liipimaginebundle: [Command] New option shortcut collides with Symfony pre-3.x default option shortcuts, causing exception when running `cache:resolve` command

Created on 6 Sep 2017  路  6Comments  路  Source: liip/LiipImagineBundle

| Q | A
| --- | ---
| Bug Report? | yes
| Feature Request? | no
| BC Break Report? | yes
| RFC? | no
| Imagine Bundle Version | 1.9.0

Hi! We're getting the following error when running php app/console liip:imagine:cache:resolve -h on an application built with Symfony 2.8:

[Symfony\Component\Console\Exception\LogicException]  
An option with shortcut "s" already exists.

This is new to 1.9.0, it doesn't happen with 1.8.0. Seems to be related to this pull request https://github.com/liip/LiipImagineBundle/pull/967/files#diff-d758689e0e797fc5329e93e432a7e196R38

Thanks!

Critical Bug 馃悶 Confirmed

All 6 comments

@Danita Thanks for the report. Looks like older versions of the Symfony console had a --shell option (which was assigned the shortcut -s) and this is colliding with the recently introduced --as-script option (which was also assigned the shortcut -s). Symfony's use of --shell was removed in 3.0+ releases, and, aside from the automated testing of older Symfony releases (which do not bring in the default Symfony console options when building the test calls, and so would not throw an error as the conflicting options are not registered), I'd only "hand-tested" the changes on 3.0+ codebases.

In the future, it would likely be sensible to extend our tests to include additional functional ones with the entire Symfony environment loaded, so issues like this can be avoided. In the immediate, I'm working on a few minor "cleanup" tweaks to the latest console changes (to ensure the transition from the 1.x console commands to the 2.x ones is seamless), as well as the fix for the issue you've encountered, of course. With some luck, a patch release will be tagged in the mid- to late-morning (I'm in EDT, or -04:00 behind UTC, for reference :-)

If you need to run those commands in the interim, you can resolve the exception by removing the s option shortcut from line 38 of Command/ResolveCacheCommand.php and replacing it with null, making the line:

->addOption('as-script', null, InputOption::VALUE_NONE, // ...

Instead of broken, current implementation of:

->addOption('as-script', 's', InputOption::VALUE_NONE, // ...

Just as a quick update, resolution waiting on https://github.com/symfony/symfony/pull/24105#issuecomment-328130035 as that PR broke our test suite (and user-facing code) for Symfony 2.7 and we never merge PRs with failing CI status.

If you need to run those commands in the interim, you can resolve the exception by removing the s option

For now we can use 1.8.0 until the issue is solved. Thanks for your quick response, it's very appreciated! 馃槃

If you have a moment, test the changes that should resolve this issue by running the following in one of your projects to fetch my latest work and run the resolve/remove command:

rm -fr vendor/liip/imagine-bundle
git clone -b feature-bugfix-console-commands https://github.com/robfrawley/LiipImagineBundle.git vendor/liip/imagine-bundle
app/console liip:imagine:cache:resolve -h
app/console liip:imagine:cache:remove -h

Yes, it worked perfectly in our setup, thanks!

@Danita The 1.9.1 release has been tagged with the fix you tested. Enjoy! And thanks for the bug report.

Was this page helpful?
0 / 5 - 0 ratings