Fix the contact merge form on Drupal 8 #11992
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.
Overview
Attempting to merge contacts which are associated with Drupal users will result in a fatal error.
Before
The steps to reproduce are basically:
Here's the stack trace we get:
After
The form works as expected!
Technical Details
The problematic code is basically two instances of this:
While
user_load()
will actually work in Drupal 8, the name field is accessed like$mainUser->name->value
(because in Drupal 8 all entity properties are fields).Instead of directly using Drupal-specific code, this PR changes to using a pre-existing method:
$config->userSystem->getUser()
However, it updates the Drupal 8 implementation to actually work, and also adds a Joomla one to make sure the name is set the same way as the original code. I don't know anything about Joomla and didn't test that, so I'll need some advice on if that was the right thing to do!
But the Drupal 8 is good, and tested :-)