Errors after upgrading to 3.0.1 from 1.14 or 1.15

Created on 20 July 2023, 11 months ago
Updated 5 February 2024, 5 months ago

Problem/Motivation

After upgrading from 1.14 (and even 1.15) to 3.0.1, The following errors appear in the logs:

[20-Jul-2023 17:03:43] WARNING: [pool www] child 9933 said into stderr: "NOTICE: PHP message: TypeError: array_values(): Argument #1 ($array) must be of type array, null given in /var/www/html/docroot/modules/contrib/gtranslate/src/Plugin/Block/GTranslateBlock.php on line 385 #0 /var/www/html/docroot/modules/contrib/gtranslate/src/Plugin/Block/GTranslateBlock.php(385): array_values(NULL)"
[20-Jul-2023 17:03:43] WARNING: [pool www] child 9933 said into stderr: "#1 /var/www/html/docroot/core/modules/block/src/BlockViewBuilder.php(171): Drupal\gtranslate\Plugin\Block\GTranslateBlock->build()"
[20-Jul-2023 17:03:43] WARNING: [pool www] child 9933 said into stderr: "#2 [internal function]: Drupal\block\BlockViewBuilder::preRender(Array)"
[20-Jul-2023 17:03:43] WARNING: [pool www] child 9933 said into stderr: "#3 /var/www/html/docroot/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array(Array, Array)"
[20-Jul-2023 17:03:43] WARNING: [pool www] child 9933 said into stderr: "#4 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')"
[20-Jul-2023 17:03:43] WARNING: [pool www] child 9933 said into stderr: "#5 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)"
[20-Jul-2023 17:03:43] WARNING: [pool www] child 9933 said into stderr: "#6 /var/www/html/docroot/core/lib/Drupal/Co..."
2023/07/20 17:03:43 [error] 2103#2103: *1703 FastCGI sent in stderr: "PHP message: TypeError: array_values(): Argument #1 ($array) must be of type array, null given in /var/www/html/docroot/modules/contrib/gtranslate/src/Plugin/Block/GTranslateBlock.php on line 385 #0 /var/www/html/docroot/modules/contrib/gtranslate/src/Plugin/Block/GTranslateBlock.php(385): array_values(NULL)
#1 /var/www/html/docroot/core/modules/block/src/BlockViewBuilder.php(171): Drupal\gtranslate\Plugin\Block\GTranslateBlock->build()
#2 [internal function]: Drupal\block\BlockViewBuilder::preRender(Array)
#3 /var/www/html/docroot/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array(Array, Array)
#4 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
#5 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#6 /var/www/html/docroot/core/lib/Drupal/Co" while reading response header from upstream, client: 172.24.0.6, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm.sock:", host: "iaapa.ddev.site"
 

Steps to reproduce

Start with a configured module on version 1.14 or 1.15, upgrade to 3.0.1 using composer, run drush updb, clear cache. Try to load the website.

Proposed resolution

It appears that the configuration page for the module has changed significantly from the 1.x version to 3.x. Once I disable the module and re-enable, everything works as expected, but the module needs to be reconfigured. I suspect that the reason for this is because there is no migration of configuration data, or at the very least, it was not processed when drush updb was called.

I have not looked at the code yet to see if I can pinpoint the issue.

Remaining tasks

Determine if configuration update is just not running or flat out missing.

🐛 Bug report
Status

RTBC

Version

3.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @pumpkinkid2
  • 🇺🇸United States eahonet

    I can confirm I ran into the same issue upgrading from 1.15.0 => 3.0.1. Your tip to disable and re-enable did work for me as well. I reconfigured and tweaked CSS to get it to work.

  • 🇮🇳India gawalin

    I ran into the same issue upgrading from 1.15.0 => 3.0.1. So I have disabled and enabled module . In the configuration when I click on the "Save Configuration " nothing is happening and error is showing in the error log.

    Error statement:
    Warning: foreach() argument must be of type array|object, null given in Drupal\Core\Render\Element\Checkboxes::valueCallback() (line 113 of C:\xampp-php-8.1\htdocs\website\docroot\core\lib\Drupal\Core\Render\Element\Checkboxes.php)

  • First commit to issue fork.
  • @zoiosilva opened merge request.
  • Status changed to Needs review 10 months ago
  • 🇧🇷Brazil zoiosilva Brazil, MS, Dourados
  • Status changed to RTBC 10 months ago
  • 🇨🇦Canada NickDickinsonWilde Victoria, BC (T'So-uke lands)

    I would argue that with no custom code in the composer.json, that relying on the drupal composer facade is more reliable - automatically copies any changes from module.info.yml. But that's very much a maintainer decision.
    The other changes make total sense/tested as working.

  • 🇧🇷Brazil zoiosilva Brazil, MS, Dourados

    Yeah, I agree. I totally forgot about that composer facade thing. But I'll leave it like that until we hear from the maintainer.

  • We ideally need an hook_update_N() setting up the default module configs.

  • Status changed to Needs work 10 months ago
  • Users shouldn't have to manually reinstall the module.

  • Status changed to Needs review 10 months ago
  • Attach a patch which attempts to generate the appropriate config as part as of a database update.

  • I have not been able to chime in here as I have been busy with a migration to D10, but I have been checking occasionally and I appreciate the progress being made here.

    I will test the patch as soon as I am able to.

  • 🇨🇭Switzerland pjo-previon

    I tested the patch on Drupal 9.5.8 with PHP 8.1, and it worked for me, the error on screen has vanished now, however I needed another patch to get rid of another error, issue: https://www.drupal.org/project/gtranslate/issues/3350875 🐛 Warning: foreach() argument must be of type array|object GTranslateBlock.php RTBC after I applied the patch from the issue in the link, I still had the error described in this issue, which was fixed by this patch. So in summary, it's safe to say that this patch does fix the problem.

  • Status changed to RTBC 9 months ago
  • 🇮🇳India abhisekmazumdar India

    I can confirm that after I upgraded this module from `drupal/gtranslate` 1.15.0 to 3.0.1 with Drupal 9.5, I am experiencing the mentioned WSFD with these error messages.

    Applying these patches resolves the issue.

  • Status changed to Needs work 8 months ago
  • 🇺🇸United States AaronBauman Philadelphia

    The errors are gone, but my settings were not preserved.

    After applying the patch and running database updates, none of the previously-configured languages are available on the widget.
    Only English is available.

  • 🇺🇸United States wylbur Minneapolis, Minnesota, USA

    I just ran this update on a fresh install from 1.15.0 to 3.0.1 with the patch from comment 11, and the configuration changes were converted and retained as config. Selected language settings were correctly converted.

    During our update, no other patches from this module were applied.

  • 🇨🇭Switzerland sraLton

    My config was also reset from all languages to:
    en, es, de, it, fr

    I would suggest to add this information to the release-notes.
    For me this error is not a game changer since its a major release.

  • 🇦🇺Australia pasan.gamage

    Unfortunately upgrading from 1.15 breaks the configs and the widget.
    It looks like a lot of the functionality has been removed from the 1.15 branch.
    Below is the diff file;
    I can agree with @sraLton this is a breaking change and should be added in the release notes.
    Is there a plan to keep the 1.15 ready for D10?

    Thanks

    diff --git a/config/sync/gtranslate.settings.yml b/config/sync/gtranslate.settings.yml
    index 5d7b168..ffb6ea0 100644
    --- a/config/sync/gtranslate.settings.yml
    +++ b/config/sync/gtranslate.settings.yml
    @@ -1,113 +1,34 @@
     _core:
       default_config_hash: Cr1Zz4OIfnOZTkDixpxKbSEOSkxTS4pH1lMNiXBUDpA
    -gtranslate_method: onfly
    -gtranslate_pro: 0
    -gtranslate_enterprise: 0
    -gtranslate_look: dropdown
    -gtranslate_flag_size: '16'
    -gtranslate_new_window: 0
    -gtranslate_main_lang: en
    -gtranslate_af: '1'
    -gtranslate_sq: '1'
    -gtranslate_ar: '1'
    -gtranslate_hy: '1'
    -gtranslate_az: '1'
    -gtranslate_eu: '1'
    -gtranslate_be: '1'
    -gtranslate_bg: '1'
    -gtranslate_ca: '1'
    -gtranslate_zh-CN: '1'
    -gtranslate_zh-TW: '1'
    -gtranslate_hr: '1'
    -gtranslate_cs: '1'
    -gtranslate_da: '1'
    -gtranslate_nl: '2'
    -gtranslate_en: '2'
    -gtranslate_et: '1'
    -gtranslate_tl: '1'
    -gtranslate_fi: '1'
    -gtranslate_fr: '2'
    -gtranslate_gl: '1'
    -gtranslate_ka: '1'
    -gtranslate_de: '2'
    -gtranslate_el: '1'
    -gtranslate_ht: '1'
    -gtranslate_iw: '1'
    -gtranslate_hi: '1'
    -gtranslate_hu: '1'
    -gtranslate_is: '1'
    -gtranslate_id: '1'
    -gtranslate_ga: '1'
    -gtranslate_it: '2'
    -gtranslate_ja: '1'
    -gtranslate_ko: '1'
    -gtranslate_lv: '1'
    -gtranslate_lt: '1'
    -gtranslate_mk: '1'
    -gtranslate_ms: '1'
    -gtranslate_mt: '1'
    -gtranslate_no: '1'
    -gtranslate_fa: '1'
    -gtranslate_pl: '1'
    -gtranslate_pt: '2'
    -gtranslate_ro: '1'
    -gtranslate_ru: '2'
    -gtranslate_sr: '1'
    -gtranslate_sk: '1'
    -gtranslate_sl: '1'
    -gtranslate_es: '2'
    -gtranslate_sw: '1'
    -gtranslate_sv: '1'
    -gtranslate_th: '1'
    -gtranslate_tr: '1'
    -gtranslate_uk: '1'
    -gtranslate_ur: '1'
    -gtranslate_vi: '1'
    -gtranslate_cy: '1'
    -gtranslate_yi: '1'
    -gtranslate_bn: '1'
    -gtranslate_bs: '1'
    -gtranslate_ceb: '1'
    -gtranslate_eo: '1'
    -gtranslate_gu: '1'
    -gtranslate_ha: '1'
    -gtranslate_hmn: '1'
    -gtranslate_ig: '1'
    -gtranslate_jw: '1'
    -gtranslate_kn: '1'
    -gtranslate_km: '1'
    -gtranslate_lo: '1'
    -gtranslate_la: '1'
    -gtranslate_mi: '1'
    -gtranslate_mr: '1'
    -gtranslate_mn: '1'
    -gtranslate_ne: '1'
    -gtranslate_pa: '1'
    -gtranslate_so: '1'
    -gtranslate_ta: '1'
    -gtranslate_te: '1'
    -gtranslate_yo: '1'
    -gtranslate_zu: '1'
    -gtranslate_my: '0'
    -gtranslate_ny: '0'
    -gtranslate_kk: '0'
    -gtranslate_mg: '0'
    -gtranslate_ml: '0'
    -gtranslate_si: '0'
    -gtranslate_st: '0'
    -gtranslate_su: '0'
    -gtranslate_tg: '0'
    -gtranslate_uz: '0'
    -gtranslate_am: '0'
    -gtranslate_co: '0'
    -gtranslate_haw: '0'
    -gtranslate_ku: '0'
    -gtranslate_ky: '0'
    -gtranslate_lb: '0'
    -gtranslate_ps: '0'
    -gtranslate_sm: '0'
    -gtranslate_gd: '0'
    -gtranslate_sn: '0'
    -gtranslate_sd: '0'
    -gtranslate_fy: '0'
    -gtranslate_xh: '0'
    +source_lang: en
    +widget_look: dropdown
    +url_structure: none
    +flag_size: 16
    +flag_style: 2d
    +globe_size: 60
    +color_scheme: light
    +alt_flags: {  }
    +wrapper_selector: .gtranslate_wrapper
    +float_position: bottom-left
    +float_switcher_open_direction: top
    +position: inline
    +switcher_open_direction: bottom
    +native_language_names: 1
    +detect_browser_language: 0
    +enable_cdn: 1
    +add_new_line: 1
    +select_language_label: 'Select Language'
    +custom_domains: 0
    +custom_domains_config: ''
    +custom_css: ''
    +languages:
    +  en: en
    +  nl: nl
    +  fr: fr
    +  de: de
    +  it: it
    +  pt: pt
    +  ru: ru
    +  es: es
    +flag_languages:
    +  en: en
    
  • First commit to issue fork.
  • 🇪🇸Spain rcodina

    I just reverted my commit on the MR. I'm sorry. The problem is that somehow the upgrade hook didn't got executed on my site. After hours of investigation, I found out that the given the drupal's registry, the update hook 9301 was really executed. However, at somepoint someone did not execute a "drush cex".

  • 🇬🇧United Kingdom fonant

    Patch in #11 works here too. Thanks!

  • I am able to confirm that patch in #11 has worked for me as well, thank you @codebymikey!

  • Status changed to RTBC 5 months ago
  • 🇺🇸United States jimafisk

    #11 worked for me, thank you!

  • 🇺🇸United States asokolov

    This #11 works for us as well, do we have any plans to release this sooner?

Production build 0.69.0 2024