WSOD when editing results and pseudoconstant labels don't match Civi

Created on 29 May 2023, over 1 year ago
Updated 5 June 2023, over 1 year ago

1.0 Problem/Motivation

When you have a CiviCRM Options field and you modify the labels, you can't edit the submissions.

2.0 Detailed steps to reproduce (embed screenshots)

* Create a form that contains a contact prefix field (Mr., Mrs., etc.). I've attached one.
* On the Build tab, change the prefix field to static options. Also modify the labels. I think it needs to be a Listbox.
* Enter a sample submission.
* Go to Results and edit the submission.
* Go to Edit. Note that the prefix you selected appears twice in the select box.
* Go to Notes and attempt to submit. Get a WSOD.

3.0 Proposed resolution

I tracked this down to the webform_civicrm_webform_submission_load function, which calls _fillCiviCRMData. civicrm_1_contact_1_contact_prefix_id is loaded correctly from the db (as an integer) but _fillCiviCRMData moves that to civicrm_1_contact_1_contact_prefix_id_raw and civicrm_1_contact_1_contact_prefix_id becomes the label.

When the labels match the data in Civi, that's no problem (owing to a quirk of API3 that you can give either label or ID). When the label varies, it causes a WSOD.

I commented out webform_civicrm_webform_submission_load and couldn't see a difference. Maybe it's not needed anymore? If so, we can remove it.

🐛 Bug report
Status

Needs review

Version

6.2

Component

CiviCRM Data Handling

Created by

🇺🇸United States MegaphoneJon

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

Comments & Activities

  • Issue created by @MegaphoneJon
  • 🇺🇸United States colemanw

    Former-but-no-longer-maintainer here just chiming in to say that behavior sounds "not good" because labels and names are only interchangeable if the site is in English. Sounds like the current behavior is gonna be broken for any non-English installs.

  • 🇨🇦Canada karing 🇨🇦

    Thanks Jon. I'll ask Jitendra to take a look.

    Also why would you want to edit these labels in the webform but not in CiviCRM options?

  • 🇺🇸United States colemanw

    The original intent of that feature was that you can change the labels of dropdown options on a per-webform basis in case they have a different meaning in different contexts, for example on a particular form you can re-label your group called "Public Mailing List" to "Yes, Sign Me Up for Mailings!"

  • 🇨🇦Canada karing 🇨🇦

    That case I understand. I was just wondering about why one would want to do that with prefix Mr, Mrs, etc (as opposed to creating new options in CiviCRM).

    We do change option labels a fair bit on all sorts of webforms and have not run into this WSOD yet.

    Thanks (as always) for the detailed and helpful report Jon!

  • 🇺🇸United States MegaphoneJon

    The use case: My client has chapters around the world, but the staff all use one of 3 languages. So Civi supports those 3 languages, but forms can be in any of several languages.

  • 🇺🇸United States MegaphoneJon

    To be clear - I think the step here is to decide whether the `webform_civicrm_webform_submission_load` is necessary. I couldn't see any difference without it, so maybe other code has matured around it?

  • 🇨🇦Canada karing 🇨🇦

    Yes, understood.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India jitendrapurohit

    @MegaphoneJon I was able to replicate the wsod on Notes submit form. But looks like in my case, the reason for the fatal error was missing submission object in src/WebformCivicrmPostProcess.php.

    Re webform_civicrm_webform_submission_load() - I agree this could be removed. Thanks for spotting it.

    I've raised a PR - https://github.com/colemanw/webform_civicrm/pull/880

    Can you please review it & confirm if it resolves the error for you as well?

  • 🇺🇸United States MegaphoneJon

    Hi @jitendrapurohit - I just tested the PR, and it didn't change the behavior for me.

    With XDebug I confirmed that your code is getting hit. I cleared cache and confirmed that the error was the same. Does this only work on submissions made after the patch, or should it work when editing submissions made before the patch was installed?

Production build 0.71.5 2024