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
Comment | File | Size | Author |
---|---|---|---|
#2 | quiz-consistently-normalize-answers-2922791-2.patch | 2.97 KB | jantoine |
|
Comments
Comment #2
jantoine CreditAttribution: jantoine as a volunteer commentedPatch attached for review.
Comment #3
djdevinDid you experience this during a programmatic update? I haven't seen this issue.
Comment #4
jantoine CreditAttribution: jantoine as a volunteer commented@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.
Comment #5
djdevinOkay, 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!