?
avatar JamesNGarrett
JamesNGarrett
11 Sep 2016

Steps to reproduce the issue

  • Install and Instantiate a new module using a Sub Form Field in its config params.
  • Edit in Frontend, add item and save (works fine)
  • Edit in Frontend, delete item and save (item still there)

Expected result

  • The param value should be removed when the subform item is deleted.

Actual result

  • The new param values are merged with the old ones creating unexpected results

Cause

The bug is caused in:
/administrator/components/com_modules/controllers/module.php

the backend save doesn't use the same code as the frontend save because the frontend passes 'json' as the jdocument's type. This leads to the params being process with line 208:

$data = array_replace_recursive($properties, $data);

Sub form field items are removed and reordered in the child items in the 'params' array. But array_replace_recursive merges the new params and the old params rather than replacing them entirely.

Suggested Fix

Presuming that the frontend module save will always pass all of the params upon save then the problem can be fixed simply be putting the following line right before the array_replace_recursive.

if(isset($data['params']))
{
    unset($properties['params']);
}

#12007

avatar JamesNGarrett JamesNGarrett - open - 11 Sep 2016
avatar JamesNGarrett JamesNGarrett - edited - 11 Sep 2016
avatar JamesNGarrett JamesNGarrett - change - 11 Sep 2016
The description was changed
avatar JamesNGarrett JamesNGarrett - edited - 11 Sep 2016
avatar JamesNGarrett JamesNGarrett - edited - 11 Sep 2016
avatar brianteeman brianteeman - change - 11 Sep 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-09-11 08:33:36
Closed_By brianteeman
avatar brianteeman brianteeman - close - 11 Sep 2016
avatar brianteeman
brianteeman - comment - 11 Sep 2016

Closed as we have a pr for testing #12007

Add a Comment

Login with GitHub to post a comment