getThirdPartySetting() on null - fix

Created on 27 March 2023, over 1 year ago
Updated 24 April 2023, about 1 year ago

Problem/Motivation

When module installed, I got the error
Error: Call to a member function getThirdPartySetting() on null in Drupal\content_translation\ContentTranslationManager->getBundleTranslationSettings()
when going on the page
/admin/structure/types/add

Uninstalling the module makes the site working again on the specified page.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇫🇷France rondev

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

Comments & Activities

  • Issue created by @rondev
  • 🇨🇦Canada joseph.olstad

    @rondev thanks for reporting, any chance you could provide us with a list of the other modules you have installed/enabled that may be conflicting with entity_translation_unified_form so that we could run some tests to reproduce this issue and fix it?

    Example:
    drush pml | grep 'enabled' -i

    what does the output of this drush command look like? Please paste the results below:

     |   |
    \|/ \|/
    
  • 🇫🇷France rondev

    Yes for sure.

      Core                  Automated Cron (automated_cron)                                     Enabled    10.0.7
      Core                  BigPipe (big_pipe)                                                  Enabled    10.0.7
      Core                  Block (block)                                                       Enabled    10.0.7
      Core                  Custom Block (block_content)                                        Enabled    10.0.7
      Core                  Breakpoint (breakpoint)                                             Enabled    10.0.7
      Core                  CKEditor 5 (ckeditor5)                                              Enabled    10.0.7
      Core                  Comment (comment)                                                   Enabled    10.0.7
      Core                  Configuration Manager (config)                                      Enabled    10.0.7
      Core                  Contact (contact)                                                   Enabled    10.0.7
      Multilingual          Content Translation (content_translation)                           Enabled    10.0.7
      Core                  Contextual Links (contextual)                                       Enabled    10.0.7
      Field types           Datetime (datetime)                                                 Enabled    10.0.7
      Core                  Database Logging (dblog)                                            Enabled    10.0.7
      Core                  Internal Dynamic Page Cache (dynamic_page_cache)                    Enabled    10.0.7
      Core                  Text Editor (editor)                                                Enabled    10.0.7
      Core                  Field (field)                                                       Enabled    10.0.7
      Core                  Field UI (field_ui)                                                 Enabled    10.0.7
      Field types           File (file)                                                         Enabled    10.0.7
      Core                  Filter (filter)                                                     Enabled    10.0.7
      Core                  Help (help)                                                         Enabled    10.0.7
      Core                  History (history)                                                   Enabled    10.0.7
      Field types           Image (image)                                                       Enabled    10.0.7
      Multilingual          Language (language)                                                 Enabled    10.0.7
      Field types           Link (link)                                                         Enabled    10.0.7
      Multilingual          Interface Translation (locale)                                      Enabled    10.0.7
      Core                  Custom Menu Links (menu_link_content)                               Enabled    10.0.7
      Core                  Menu UI (menu_ui)                                                   Enabled    10.0.7
      Core                  MySQL (mysql)                                                       Enabled    10.0.7
      Core                  Node (node)                                                         Enabled    10.0.7
      Field types           Options (options)                                                   Enabled    10.0.7
      Core                  Internal Page Cache (page_cache)                                    Enabled    10.0.7
      Core                  Path (path)                                                         Enabled    10.0.7
      Core                  Path alias (path_alias)                                             Enabled    10.0.7
      Core                  Search (search)                                                     Enabled    10.0.7
      Core                  Shortcut (shortcut)                                                 Enabled    10.0.7
      Core                  System (system)                                                     Enabled    10.0.7
      Core                  Taxonomy (taxonomy)                                                 Enabled    10.0.7
      Field types           Text (text)                                                         Enabled    10.0.7
      Core                  Toolbar (toolbar)                                                   Enabled    10.0.7
      Core                  Tour (tour)                                                         Enabled    10.0.7
      Core                  Update Manager (update)                                             Enabled    10.0.7
      Core                  User (user)                                                         Enabled    10.0.7
      Core                  Views (views)                                                       Enabled    10.0.7
      Core                  Views UI (views_ui)                                                 Enabled    10.0.7
      Multilingual          Entity Translation Unified Form (entity_translation_unified_form)   Enabled    2.0.0-rc4
      Menu                  Taxonomy Menu (taxonomy_menu)                                       Enabled
      Core                  Claro (claro)                                                       Enabled    10.0.7
      Core                  Olivero (olivero)                                                   Enabled    10.0.7
    

    It is quite a new site, almost empty.

  • Status changed to Needs work over 1 year ago
  • 🇨🇦Canada joseph.olstad

    I'm going on vacation for a bit so hoping someone else can have a closer look.

  • @joseph.olstad i did installed Entity Translation Unified Form module for drupal 10 and access the url admin/structure/types/add i got same error which you got i did debug in module file function entity_translation_unified_form_save_only_button called inside the function content_translation.manager service call in getBundleTranslationSettings function config getThirdPartySetting given the error. and found solution
    to add condition like that

    diff --git a/core/modules/content_translation/src/ContentTranslationManager.php b/core/modules/content_translation/src/ContentTranslationManager.php
    index 56ac55cf7e..dcc5280bab 100644
    --- a/core/modules/content_translation/src/ContentTranslationManager.php
    +++ b/core/modules/content_translation/src/ContentTranslationManager.php
    @@ -119,7 +119,10 @@ public function setBundleTranslationSettings($entity_type_id, $bundle, array $se
    */
    public function getBundleTranslationSettings($entity_type_id, $bundle) {
    $config = $this->loadContentLanguageSettings($entity_type_id, $bundle);
    - return $config->getThirdPartySetting('content_translation', 'bundle_settings', []);
    + if ($config = $this->loadContentLanguageSettings($entity_type_id, $bundle)) {
    + return $config->getThirdPartySetting('content_translation', 'bundle_settings', []);
    + }
    + return [];
    }

    /**

  • 🇨🇦Canada joseph.olstad

    @mukesh88

    prefer patching entity_translation_unified_form instead of core
    have a look at line 222 of entity_translation_unified_form.module

    line 236
    line 251
    line 265
    line 284
    line 299
    line 313
    line 328
    line 342
    line 357
    line 374
    line 594

    These lines are the ones that trigger the core and for D10 result in a crash.

    $content_translation_manager = \Drupal::service('content_translation.manager');
    if ($content_translation_manager instanceof BundleTranslationSettingsInterface) {
    
  • 🇨🇦Canada joseph.olstad

    Call to a member function getThirdPartySetting() on null in ContentTranslationManager

  • 🇨🇦Canada joseph.olstad

    ah yes, seven, I will add a patch to fix this

  • 🇨🇦Canada joseph.olstad

    ok, so turns out I forgot that my environments are using a core patch that resolves this issue.

    #2868294-87: Call to a member function getThirdPartySetting() on null in ContentTranslationManager

    To fix this issue, use this core patch.

  • Status changed to Needs review about 1 year ago
  • 🇨🇦Canada joseph.olstad

    Hmm, actually I think there's another fix for this, looking into it now

  • Assigned to joseph.olstad
  • Status changed to Fixed about 1 year ago
  • 🇨🇦Canada joseph.olstad

    no need for core patch when using 2.0.0-rc5 instead of rc4

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024