Warnings and errors (WSOD) when using multilingual Drupal website.

Created on 18 August 2023, 11 months ago
Updated 26 August 2023, 10 months ago

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.

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland snsblvd

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @snsblvd
  • πŸ‡¨πŸ‡­Switzerland snsblvd

    I 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.

Production build 0.69.0 2024