web-vision / wv_deepltranslate

TYPO3 Extension to translate content and TCA records with DeepL Translate
GNU General Public License v2.0
25 stars 41 forks source link

[BUG] Exception during deepl:glossary:list #367

Open vertexvaar opened 1 month ago

vertexvaar commented 1 month ago

Describe the bug

$ vendor/bin/typo3 deepl:glossary:list
============
Read more here: https://www.deepl.com/docs-api/managing-glossaries/listing-glossaries/
============

Uncaught TYPO3 Exception Symfony\Component\Console\Helper\Table::addRow(): Argument #1 ($row) must be of type Symfony\Component\Console\Helper\TableSeparator|array, DeepL\GlossaryInfo given, called in /app/app/vendor/symfony/console/Helper/Table.php on line 210
thrown in file /app/app/vendor/symfony/console/Helper/Table.php
in line 219

To Reproduce

Exception with Stacktrace

TypeError: Symfony\Component\Console\Helper\Table::addRow(): Argument #1 ($row) must be of type Symfony\Component\Console\Helper\TableSeparator|array, DeepL\GlossaryInfo given, called in /app/app/vendor/symfony/console/Helper/Table.php on line 210 and defined in /app/app/vendor/symfony/console/Helper/Table.php:219
Stack trace:
#0 /app/app/vendor/symfony/console/Helper/Table.php(210): Symfony\Component\Console\Helper\Table->addRow(Object(DeepL\GlossaryInfo))
#1 /app/app/vendor/symfony/console/Helper/Table.php(201): Symfony\Component\Console\Helper\Table->addRows(Array)
#2 /app/app/vendor/web-vision/wv_deepltranslate/Classes/Command/GlossaryListCommand.php(71): Symfony\Component\Console\Helper\Table->setRows(Array)
#3 /app/app/vendor/web-vision/wv_deepltranslate/Classes/Command/GlossaryListCommand.php(36): WebVision\WvDeepltranslate\Command\GlossaryListCommand->listAllGloassaryEntries(Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /app/app/vendor/symfony/console/Command/Command.php(326): WebVision\WvDeepltranslate\Command\GlossaryListCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /app/app/vendor/symfony/console/Application.php(1096): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /app/app/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(WebVision\WvDeepltranslate\Command\GlossaryListCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /app/app/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /app/app/vendor/typo3/cms-core/Classes/Console/CommandApplication.php(112): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /app/app/vendor/typo3/cms-cli/typo3(23): TYPO3\CMS\Core\Console\CommandApplication->run()
#10 /app/app/vendor/typo3/cms-cli/typo3(24): {closure}()
#11 /app/app/vendor/bin/typo3(119): include('/app/app/vendor...')
#12 {main}

TYPO3 Setup

Composer install in docker

typo3/cms-core                            12.4.21
web-vision/wv_deepltranslate              4.3.1
symfony/console                           6.4.12
deeplcom/deepl-php                        1.9.0
vertexvaar commented 1 month ago

quick fix with composer patches

Index: Classes/Command/GlossaryListCommand.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Classes/Command/GlossaryListCommand.php b/Classes/Command/GlossaryListCommand.php
--- a/Classes/Command/GlossaryListCommand.php   
+++ b/Classes/Command/GlossaryListCommand.php   (date 1729065678558)
@@ -62,7 +62,9 @@
         $rows = [];

         foreach ($glossaries as $eachGlossary) {
-            $rows[] = $eachGlossary;
+            $row = (array) $eachGlossary;
+            $row['creationTime'] = $row['creationTime']->format('Y-m-d H:i:s');
+            $rows[] = $row;
         }

         $table = new Table($output);
calien666 commented 2 days ago

Hey @vertexvaar Could you please check, if the error still appears in latest main branch? Quite after the last release we changed this part and updated the listing of the glossaries, which will get into next release. This means, your patch is valid for 4.3.1, but not for latest main.

I'm sorry for this late feedback about this. I will be appreciated about a feedback from you.