Ajax error because of PHP 7.4, Trying to access array offset on value of type null

Created on 24 August 2020, over 4 years ago
Updated 24 May 2023, over 1 year ago

Ajax error doesn't allow me to add paragraph, that is using a field with attached states logic

Create a paragraph type. Add select field and input field to this paragraph. Attach states logic to input field, that is related to select list value. When you are on node edit page and try yo add this paragraph, ajax error blocks the action. ""

Proposed resolution is to add check for the variable value.

πŸ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡§πŸ‡¬Bulgaria rkostov

    The patch from #11 works well here! Thank you!

  • πŸ‡ΊπŸ‡ΈUnited States ja09

    I'm getting this error with PHP 8.1, D 9.5, and field_states_ui 3.0.0.

    #11 seems to resolve it. Thank you!

  • Status changed to RTBC about 1 year ago
  • πŸ‡ͺπŸ‡ΈSpain manuel garcia

    Updating the title as this isn't just PHP 7.4.
    Taking the leap here and moving to RTBC, it is being reported as valid, patch is small and looks good to me. Thank you @godotislate.

  • πŸ‡«πŸ‡·France bakop Lille

    RTBC + 1 -> Working on Drupal 10.3.1

  • πŸ‡ΊπŸ‡ΈUnited States jvest

    Tested patch #11 with v3.0.0 on Drupal core 10.2.11 and PHP 8.1.29 ... resolves warning messages.

  • πŸ‡©πŸ‡ͺGermany kopfduenger Wiesbaden

    Patch #11 unfortunately did not worked for me anymore. I am on Drupal Version 10.3.10, PHP 8.1.30. Drupal log was flooded with messages as

    Warning: Undefined array key "simple_sitemap" in Drupal\field_ui\Form\EntityDisplayFormBase->copyFormValuesToEntity() (Zeile 643 in /var/www/html/web/core/modules/field_ui/src/Form/EntityDisplayFormBase.php).

    and

    Warning: Trying to access array offset on value of type null in Drupal\field_ui\Form\EntityDisplayFormBase->copyFormValuesToEntity() (Zeile 643 in /var/www/html/web/core/modules/field_ui/src/Form/EntityDisplayFormBase.php).

    Even worse, on my local installation, the fields on content types' form display page (admin/structure/types/manage//form-display) could not be edited anymore, showing more and more of these messages on top of the page, leading to:

    *Drupal\Core\Database\DatabaseExceptionWrapper*: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT 1 AS "expression" FROM "sessions" "sessions" WHERE "sid" = :db_condition_placeholder_0; Array ( [:db_condition_placeholder_0] => bSH7ZZvbRVb_7-exNS2ItOFW-U3CvuFPPFamw54fVuM ) in *Drupal\Core\Session\SessionHandler->Drupal\Core\Session\{closure}()* (line *95* of */app/web/core/lib/Drupal/Core/Session/SessionHandler.php*)

    This post directed me to the right solution: Stackoverflow – Message: Trying to access array offset on value of type null
    The function copyFormValuesToEntity() in core/modules/field_ui/src/Form/EntityDisplayFormBase.php did not check for value NULL and existence of array value in two places. Previous versions of PHP may have been less strict on such mistakes and silently swallowed the error / notice.
    Here is a patch β†’ that works for in our drupal installation. Hope it helps.

  • πŸ‡©πŸ‡ͺGermany kopfduenger Wiesbaden
Production build 0.71.5 2024