Problem/Motivation
When I capture translations of content I get "Warnings" and when I try to translate a custom block I get a WSOD error.
Drupal 9.5.10
PHP 8.1.22
Multilanguage (german default; english) for interface and content
Steps to reproduce
Since I installed chatgpt_plugin, I often get this error message in the background (when I translate content):
Warning: Undefined array key "translation" in Drupal\chatgpt_plugin\Controller\ChatGPTTranslateController->insertTranslation() (line 197 of /home/drupal/webapps/bukanier/web/modules/contrib/chatgpt_plugin/src/Controller/ChatGPTTranslateController.php)
If I also want to translate a e.g. custom block (/admin/structure/block/block-content) I get a WSOD with the error message: The website encountered an unexpected error. Please try again later.
Error message is then:
Error: Call to a member function hasTranslation() on null in Drupal\chatgpt_plugin\Form\ChatGPTTranslateForm->buildForm() (line 95 in /home/drupal/webapps/bukanier/web/modules/contrib/chatgpt_plugin/src/Form/ChatGPTTranslateForm.php)
Proposed resolution
Module should take multilanguage into account and at least not produce WSOD.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | ChatGPTTranslate-wsod.patch | 1.43 KB | snsblvd |
| WSOD-Error_Detail.txt | 3.28 KB | snsblvd |
Comments
Comment #2
snsblvd commentedI have created a patch (only lightly tested with my drupal 9 installation, use at your own risk) that prevents the warning message and especially "fixes" the main bug with the WSOD. But that's probably also the reason why the module now doesn't offer translation via ChatGPT on the custom block. For normal content, the translation options via ChatGPT are still offered. Hope someone with more knowhow could look at this in detail.
Comment #3
snsblvd commentedif I use the latest version (2.1.5) I cant reproduce those errors (was initially with d9, now with drupal 11 / php 8.3). so I'll close my issue.