wearerequired / traduttore

🗼 A WordPress plugin to improve the I18N workflow for your own projects based on @GlotPress.
https://wearerequired.github.io/traduttore/
72 stars 15 forks source link

Bug: `language-pack list` critically fails when no project language packs exist #241

Closed rbackert closed 2 months ago

rbackert commented 1 year ago

Issue Overview WP CLI command wp traduttore language-pack list <project> critically fails if no language packs exist for the project.

To Reproduce Steps to reproduce the behavior:

  1. Start with a fresh install of traduttore
  2. Run wp traduttore language-pack list <project>
  3. See critical error in command line and error log

Expected behavior If the project there's no last generated date, then language-pack list should show empty output in the selected --format.

Screenshots If applicable, add screenshots to help explain your problem.

Versions

Additional context Error log:

PHP Fatal error:  Uncaught Error: Call to a member function format() on null in /wp/wp-content/plugins/traduttore/inc/CLI/LanguagePackCommand.php:104
Stack trace:
#0 [internal function]: Required\Traduttore\CLI\LanguagePackCommand->list(Array, Array)
#1 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func(Array, Array, Array)
#2 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#3 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_func(Object(Closure), Array, Array)
#4 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(417): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array)
#5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(440): WP_CLI\Runner->run_command(Array, Array)
#6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1237): WP_CLI\Runner->run_command_and_exit()
#7 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php in /wp/wp-content/plugins/traduttore/inc/CLI/LanguagePackCommand.php on line 104