? Pending

User tests: Successful: Unsuccessful:

avatar stutteringp0et
stutteringp0et
19 Nov 2017

Changing user groups via JUserHelper without first setting a task input variable to activate, block or unblock deletes ALL user values from #__fields_values. $model->setFieldValue deletes records where the value is null. This change tests for a null value before calling setFieldValue to prevent that deletion.

Pull Request for Issue # .

Summary of Changes

Test for null value to prevent the fields model from deleting user values from the table.

Testing Instructions

Create a system plugin that calls JUserHelper::setUserGroups

Before the patch, all user field values for the updated user will be deleted.

After the patch, all user field values for the updated user will remain.

Prior to this change, I had to JFactory::getApplication()->input->set('task','unblock'); in order to update user groups without losing all of their field data.

Expected result

User fields remain

Actual result

User fields are deleted

Documentation Changes Required

avatar stutteringp0et stutteringp0et - open - 19 Nov 2017
avatar stutteringp0et stutteringp0et - change - 19 Nov 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 19 Nov 2017
Category Front End Plugins
avatar stutteringp0et stutteringp0et - change - 19 Nov 2017
Labels Added: ?
avatar stutteringp0et stutteringp0et - change - 19 Nov 2017
Title
Update fields.php
Prevent PlgSystemFields::onContentAfterSave from deleting user values from #__fields_values
avatar stutteringp0et stutteringp0et - edited - 19 Nov 2017
avatar stutteringp0et
stutteringp0et - comment - 21 Nov 2017

plg_system_pr18701.zip
Attached: A system plugin to test this PR.

This plugin has 3 configurations. User, Group, and Method.

Choose a user to manipulate
Choose a group to toggle membership
Choose a method to perform the group update

You must first create at least one user custom field and fill it with a value for the test user.

This plugin toggles the group membership for the selected user on every page load. Regardless of the method, all field values are lost for the user before this PR.

Note, this plugin does not do anything when saving a user profile, only on page refreshes/loads.

Once this PR is applied, this plugin has no effect on field values for the user.

avatar stutteringp0et
stutteringp0et - comment - 5 Dec 2017

What if the new value is 0 (zero)? The "if($value)" test would fail and the field would not be updated. Even a string 0 fails that test.

avatar tonypartridge
tonypartridge - comment - 5 Dec 2017

Of course, good point!

On 5 Dec 2017, 03:03 +0000, Michael Richey notifications@github.com, wrote:

What if the new value is 0 (zero)? The "if($value)" test would fail and the field would not be updated.

You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

avatar stutteringp0et
stutteringp0et - comment - 6 Dec 2017

To explain my thinking on this - when a field doesn't exist in the request, PlgSystemFields sets it to null. There is no way for a user to submit a null, so the only way for it to be null is if it is missing from the request. This PR is just ignoring the nulls.

avatar stutteringp0et
stutteringp0et - comment - 8 Dec 2017

@laoneo - isn't com_fields your thing?

avatar joomdonation
joomdonation - comment - 8 Dec 2017

@stutteringp0et Just for your information, the problem is more difficult than your propose fix because we have to deal with Checkboxes, Checkbox custom field types. You can see the two PRs try to deal with it:

#18207
#17837

avatar stutteringp0et
stutteringp0et - comment - 8 Dec 2017

That's a lot of eyeballs on the problem. I hadn't considered checkboxes. Closing this PR.

Thanks for pointing me to the others.

avatar stutteringp0et stutteringp0et - change - 8 Dec 2017
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2017-12-08 07:36:21
Closed_By stutteringp0et
avatar stutteringp0et stutteringp0et - close - 8 Dec 2017

Add a Comment

Login with GitHub to post a comment