Problem
When "Display options" is unselected on the H5P configuration page, admin/config/system/h5p, saving an H5P node does not correctly store param data from H5P object.
Steps to reproduce
- Install a vanilla H5P instance, or verify "Display options" is checked in H5P config page (admin/config/system/h5p)
- Create a H5P node using Iframe Embedder (This is the object I tested with)
- Uncheck "Display options" on H5P config page (admin/config/system/h5p)
- Edit and save H5P node
- Node now displays "Page not found"
- Edit node and observe that Width, Min width, Height, and Source fields are empty
- Observe database values in h5p_nodes json_content and filtered fields are incorrect
Problem Cause
The _h5p_form_submit function is not attached to the H5P node edit form unless "Display options" is selected.
// Display options
if (variable_get('h5p_frame', TRUE)) {
$form['h5p_options'] = array(
// [...]
);
// Add display options
// [...]
$form['#submit'][] = '_h5p_form_submit';
}
return $form;
_h5p_form_submit() performs: $form_state['values']['json_content'] = json_encode($json_content->params);. Without this operation, the node json_content field is incorrectly stored and the filter field contains "{}".
Proposed resolution
Move $form['#submit'][] = '_h5p_form_submit'; outside the if statement.
Mitigation
Selecting "Display options" but not enabling any of the buttons produces give output similar or the same to disabling "Display options" and allows data to be saved correctly.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3025138-1-Node-save-bug.patch | 546 bytes | dale42 |
Comments
Comment #2
dale42Here is a patch that moves _h5p_form_submit outside the if statement.
Comment #3
szeidlerI also experience the issue since the update to the recent version: 7.x-1.39. The dev version is also affected. For existing H5P content it results in a data loss.
I tested the patch #1 and it resolves the issue. The submit handler must be placed outside of the option condition.
Comment #5
paalj commentedThis was a ugly bug :(
Thanks for letting us know. The fix will be part of the upcoming release.
Comment #6
paalj commented