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.

CommentFileSizeAuthor
#2 3025138-1-Node-save-bug.patch546 bytesdale42

Comments

dale42 created an issue. See original summary.

dale42’s picture

StatusFileSize
new546 bytes

Here is a patch that moves _h5p_form_submit outside the if statement.

szeidler’s picture

Version: 7.x-1.39 » 7.x-1.x-dev
Status: Active » Reviewed & tested by the community

I 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.

  • paalj committed f214294 on 7.x-1.x authored by dale42
    Issue #3025138 by dale42, szeidler: Turning off “Display options” breaks...
paalj’s picture

This was a ugly bug :(

Thanks for letting us know. The fix will be part of the upcoming release.

paalj’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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