? ? Pending

User tests: Successful: Unsuccessful:

avatar Denitz
Denitz
3 Oct 2017

Summary of Changes

Main concept is:

  1. checkbox and checkboxes fields have a special property $ensure_value to indicate that these fields require any value.

JForm::filter() method now accepts $ensure_values param enabled by default, hence the filtered data always have values for such fields (hence saving empty checkbox will have data)

  1. Custom fields plugin only updates the value which really exists in $data['com_fields']

Result: no custom fields data is lost on items save and checkboxes fine in forms as well.

No BC breaks.

Related to #18188, #17837, #17801.

Testing Instructions

Save users/articles with checkboxes custom fields.

Ensure that checked, unchecked data is saved.

Save user profiles, reset password, block/unblock/activate users, ensure that no custom fields values are lost.

Perform direct JUser::save() related operations, ensure that no custom fields values are lost:

$user = JFactory::getUser($USER_ID);
$user->save();

JUserHelper::addUserToGroup();
JUserHelper::removeUserFromGroup();
avatar joomla-cms-bot joomla-cms-bot - change - 3 Oct 2017
Category Libraries Front End Plugins
avatar Denitz Denitz - open - 3 Oct 2017
avatar Denitz Denitz - change - 3 Oct 2017
Status New Pending
avatar Denitz Denitz - change - 3 Oct 2017
Labels Added: ?
avatar laoneo
laoneo - comment - 4 Oct 2017

I guess there are more form fields which do not send data when nothing is selected like radio buttons, or I'm wrong?

avatar Denitz
Denitz - comment - 4 Oct 2017

Basically yes, but if a field does not have value for radio (unchecked), it won't have value in $data, hence it's correct.

Single selected radio can't be unchecked and will always have value in POST, multiple radios with checked value will always have a value in POST.

Radio just can't imitate the problematic behaviour of checkbox when current state is checked and we save unchecked field, radio can't be unchecked to none-value.

avatar Denitz
Denitz - comment - 4 Oct 2017

Btw it's strange that here I see continuous-integration/drone/pr — this build is pending but http://ci.joomla.org/joomla/joomla-cms/133 looks like completed and without issues.

avatar Trossler
Trossler - comment - 9 Oct 2017

it is still open
@Denitz ... someone tested it ... do you know something?
work the changed files also in 3.8.1?

avatar Denitz
Denitz - comment - 10 Oct 2017

@Trossler Not sure, it looks like ignored. It works for 3.8.1

IMHO this is the solid approach for data updates and form fields, but we have other crutch-based PRs :(

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 10 Oct 2017

@Trossler we need 2 successfully Tests, which isn't now.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 28 Oct 2017

@Trossler can you please test?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18207.

avatar laoneo
laoneo - comment - 8 Dec 2017

I really would like to get the thing sorted. Can you test, that the following situations do work:

  • $user = JFactory::getUser(); $user->save();Should not erase the data.
  • Password reset is not erasing the data
  • If you have one checkbox field and you save the article with it checked and the second time unchecked, that it works.
  • Same with radio.
  • Same with select box.

If this cases do work, then I'm convinced that we are pretty much on the safe side and I will be willing to close #17837 in favor of this one. Thanks for all the work to get it fixed properly.

avatar franz-wohlkoenig franz-wohlkoenig - change - 8 Dec 2017
Status Pending Information Required
avatar joomdonation joomdonation - test_item - 19 Dec 2017 - Tested successfully
avatar joomdonation
joomdonation - comment - 19 Dec 2017

I have tested this item successfully on 2dfebca

Applied the patch, tested all cases mentioned by @Denitz and @laoneo and it is working as expected, did quick code review, too. I think this is a big bug and should be fixed in 3.8.4 if it is possible


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18207.

avatar joomdonation
joomdonation - comment - 19 Dec 2017

BTW, do we have code style rule for property name, variable name or parameter name?

So $ensureValues instead of $ensure_values and so on. Please also make code style change as requested by @Quy so that we can get it merged (hopefully)

avatar laoneo
laoneo - comment - 19 Dec 2017

Thanks @joomdonation for the test. Agree, this needs to be fixed for 3.8.4.

avatar franz-wohlkoenig franz-wohlkoenig - change - 19 Dec 2017
Title
com_fields fix with deleting data on item update, forms checkbox fix
[com_fields] fix with deleting data on item update, forms checkbox fix
avatar joomla-cms-bot joomla-cms-bot - edited - 19 Dec 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Dec 2017

@Denitz can you please resolve conflicting Files so this Pull Request can be tested?

d593e7c 26 Dec 2017 avatar Denitz fix
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Dec 2017

@joomdonation can you please retest?

@Quy can you please test?

avatar joomdonation
joomdonation - comment - 26 Dec 2017

Look like the file fields.php.orig was committed by mistake, please remove it

07e601b 26 Dec 2017 avatar Denitz fix
avatar joomdonation
joomdonation - comment - 26 Dec 2017

Could you please also fix since tag as requested by @Quy ? Right now, it is hardcoded to 3.8.1

avatar Denitz
Denitz - comment - 26 Dec 2017

Sorry, where is it?

09fb863 26 Dec 2017 avatar Denitz fix
15471a5 26 Dec 2017 avatar Denitz fix
avatar joomdonation joomdonation - test_item - 27 Dec 2017 - Tested successfully
avatar joomdonation
joomdonation - comment - 27 Dec 2017

I have tested this item successfully on 15471a5

Tested it again today, still work as expected.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18207.

avatar Quy Quy - test_item - 30 Dec 2017 - Tested successfully
avatar Quy
Quy - comment - 30 Dec 2017

I have tested this item successfully on 15471a5


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18207.

avatar Quy Quy - change - 30 Dec 2017
Status Information Required Ready to Commit
avatar Quy
Quy - comment - 30 Dec 2017

RTC

avatar laoneo laoneo - test_item - 8 Jan 2018 - Tested successfully
avatar laoneo
laoneo - comment - 8 Jan 2018

I have tested this item successfully on 15471a5


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18207.

avatar joomdonation
joomdonation - comment - 15 Jan 2018

@mbabker Could this PR get into 3.8.4?

avatar zero-24
zero-24 - comment - 16 Jan 2018

@Denitz can you take a look into the conflicted file?

avatar Denitz Denitz - change - 16 Jan 2018
Labels Added: ?
avatar mbabker
mbabker - comment - 19 Jan 2018

Looking at this, it doesn't feel right that the filtering method is now responsible for setting default values on form data. This should really be part of binding data to the form, and inherently the bind method, unless there is some specific need for it to happen at the filtering step.

avatar Denitz
Denitz - comment - 19 Jan 2018

Sounds logic, but we need to make it work for current code.
JForm::filter() checks all fields and returns updated data which is next used.
JForm::bind() doesn't return data and checks only passed data.

avatar mbabker
mbabker - comment - 19 Jan 2018

Something doesn't feel right about this. Filtering the data shouldn't result in a data array with more info than what it was given, that's what's making me uncomfortable about clicking the merge button right now (ya it works but it's hard to ignore my gut feeling that this isn't right at the moment).

avatar Denitz Denitz - change - 19 Jan 2018
The description was changed
avatar Denitz Denitz - edited - 19 Jan 2018
avatar Denitz
Denitz - comment - 20 Jan 2018

Please delete this PR in this case, there is nothing left to discuss here. 4th month is passing, wasted time.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 20 Jan 2018

@Denitz should i close this PR?

avatar Denitz
Denitz - comment - 20 Jan 2018

Sure, let there be bugs and crutches. I wish it could be permanently deleted from both Github and my memory as well.

avatar brianteeman brianteeman - change - 20 Jan 2018
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2018-01-20 17:43:03
Closed_By brianteeman
avatar brianteeman brianteeman - close - 20 Jan 2018
avatar mbabker
mbabker - comment - 20 Jan 2018

I'm not saying the PR should be rejected to be clear here. Just on an architectural review, this feels like it is not the appropriate solution. A filtering API method by its name should indicate that it filters the given data, not add extra data to the input source. If this is really the only solution to the problem, so be it, but I am personally not comfortable with it right now. Nothing more, nothing less.

Add a Comment

Login with GitHub to post a comment