TypeError unflatten() must be of type array, null given

Created on 26 March 2025, 12 days ago

Problem/Motivation

When user selected custom fields for translation but fields in some cases do not return any data for translation fatal error occurs.

TypeError: Drupal\tmgmt\Data::unflatten(): Argument #1 ($flattened_data) must be of type array, null given,
called in /web/modules/contrib/tmgmt_deepl/src/Plugin/tmgmt/Translator/DeeplTranslator.php on line 605 in
Drupal\tmgmt\Data->unflatten() (line 93 of /web/modules/contrib/tmgmt/src/Data.php).

πŸ› Bug report
Status

Active

Version

2.2

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine andriic

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

Merge Requests

Comments & Activities

  • Issue created by @andriic
  • Pipeline finished with Success
    12 days ago
    Total: 340s
    #458257
  • πŸ‡©πŸ‡ͺGermany SteffenR Germany

    Thanks for the finding. We never run into those issues on our projects.
    I would suggest du check beforehand, if $results['translation'] is really and array and is not empty. Otherwise, we would add empty translateData to the job_item, which is not neccessary.

  • πŸ‡ΊπŸ‡¦Ukraine andriic

    hi @steffenr,
    If we will not add translatedData to the job it will stay in "In progress" state forever, which is not correct since there's nothing to translate and job could be reviewed.
    It could confuse users and push them to delete and re-add job again and again.

  • πŸ‡©πŸ‡ͺGermany SteffenR Germany

    @andriic: Okay - than your suggestion makes sense.
    Can you give me some more information on how to reproduce the issue?
    You are writing about "Custom fields" which don't return arrays - can you give some examples?

    Thx.

  • πŸ‡ΊπŸ‡¦Ukraine andriic

    in our case we're using https://www.drupal.org/project/tablefield β†’ as a translatable field.

  • πŸ‡©πŸ‡ͺGermany SteffenR Germany

    @andriic: I've extended an existing content type with a tablefield (using latest stable 3.x release of the module) and tmgmt_deepl 2.2.9.
    Unfortunately i cannot reproduce the issue - translations are working fine - also for translatable tablefield fields.
    While translating table field content is not shown while reviewing the translation within the job. The only field which is translatable in this case is the caption field.

Production build 0.71.5 2024