Problem/Motivation

When updating a multi-choice question, I received an error about a mismatch in the number of parameters when writing to the quiz_multichoice_answers table. This was caused because $alternatives['feedback_if_not_chosen']['value'] was set to NULL and so the isset() call was returning FALSE leaving $alternatives['feedback_if_not_chosen'] an array.

Proposed resolution

If $alternatives['feedback_if_not_chosen'] or similar keys are an array, they should be set to a single value regardless of other conditions in order for insert and update functions to work. Rather than using isset(), array_key_exists() can be used when re-setting the value of these keys.

Remaining tasks

  • Review patch
  • Commit
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jantoine created an issue. See original summary.

jantoine’s picture

Assigned: jantoine » Unassigned
Issue summary: View changes
Status: Active » Needs review
FileSize
2.97 KB

Patch attached for review.

djdevin’s picture

Did you experience this during a programmatic update? I haven't seen this issue.

jantoine’s picture

@djdevin, That's correct. I just completed a migration using my latest patch from #2047499: Add support for Migrate module.. Perhaps there is a bug in the patch, but the patch attached to this issue fixes the issue with no side effects.

djdevin’s picture

Status: Needs review » Fixed

Okay, I think I see the issue. Since it fixes issues with migrate and looks generally better, plus doesn't break any tests, looks fine to commit. Thanks!

  • djdevin committed e7f17c5 on 7.x-5.x authored by jantoine
    Issue #2922791 by jantoine: Answers not consistently normalized
    

Status: Fixed » Closed (fixed)

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