fix for error handling saveUser function #6275
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request for Issue # new
Summary of Changes
the current implementation of saving the (joomla) user is not handling any errors correct.
It tries a try / catch to catch all errors generated by the User object bind and save or by user plugins (onUserbeforeSave) but the Joomla User object catches any errors itself and sets these in the User object. It then returns with a false. Therefore the catch will never be executed.
this PR corrects the error handling by testing for a false (both bind and save) and if one of these returned false, it enqueues the error message that is set in the Joomla User object.
When the user saving now fails due to Joomla or a plugin, the correct error message is displayed instead of the profile saved message.
Testing Instructions
In a (existing) system plugin, create the folowing function:
Now when saving your user profile in the front-end you should see the correct error 'Oepsie...' preventing the saving of the profile.