User tests: Successful: Unsuccessful:
Pull Request for Issue # .
When someone register for an account and registration is failed for some reasons (for example, use an existing username or existing email), users will be redirected back to registration form with error messages explain the reason of errors. However, the data which he entered before is lost and he will have to re-enter again to register for an account. This PR fixes that issue
Install Joomla
Try to register for an account, use an existing username
Before patch, you will be redirected back to register form. However, the data you entered before is cleared
After patch, you will be redirected back tor registration form, but the data you entered before is kept
For some reasons, the UsersViewRegistration class defines $data property (although I could not see it is used anywhere). When this line of code is called https://github.com/joomla/joomla-cms/blob/staging/components/com_users/views/registration/view.html.php#L41, the method getData of UsersModelRegistration is called. A form is created and cached without loading data from session https://github.com/joomla/joomla-cms/blob/staging/components/com_users/models/registration.php#L247
Later, when this command is called to get form object for view https://github.com/joomla/joomla-cms/blob/staging/components/com_users/views/registration/view.html.php#L42, the system uses the blank cached form and that's the reason form data is lost
As $data property is not used anywhere, I just remove it and remove$this->data = $this->get('Data'); calls, it is now working as expected
Status | New | ⇒ | Pending |
Category | ⇒ | Front End com_users |
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
Ready to Commit after two successful tests.
I have performed a successful test. But...
If you leave after a failed registration attempt the registration page and you come back again,
then you would expect that the (confidential) data would have disappeared.
That is not the case right now. !!!
Is that the intention?
@sandewt Yes, that is the way how Joomla handles submitted form data. When there is a validation errors and data could not be saved, Joomla will stores the form data in session and then redirect users back to the previous page so that users can correct the wrong data
As the data stored in session, if you leave the page and access again later, the data will still be there. It will be erased when session expired. Also, just want to make it clear that only you see that data on your own computer, other users won't see it.
Hi @joomdonation, do not get me wrong.
I think it's a big improvement.
The mechanism is known to me.
On closer inspection, see also issue #17743 (Contact form loses data), there is the same thing.
Hi @joomdonation, there is NO problem with this PR.
I keep going back and forth on this because there is technically a B/C break here by removing the data property (since component layouts are in scope of the view class, the property is accessible to layouts). My gut says if this is to be merged it should go into 3.9 with the note of the potential (albeit highly unlikely) B/C break, and not included in a patch release.
Strange that someone introduced this property without any usage in the core. A workaround to fix this issue without B/C is change ordering of method call to:
$this->form = $this->get('Form');
$this->data = $this->get('Data');
Please let me know if that's OK and I will make this change to have the issue fixed. It is not nice to have to re-enter data when validation failed.
Labels |
Added:
?
|
I have tested this item
I have tested this item
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-01-16 22:39:20 |
Closed_By | ⇒ | mbabker | |
Labels |
Added:
?
|
I have tested this item✅ successfully on d36f981
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19145.