Problem/Motivation
To reproduce:
a) Create a help topic.
b) Edit the help topic, changing the ID of the topic.
You will get an error similar to this:
The website encountered an unexpected error. Please try again later.
Drupal\Core\Config\ConfigDuplicateUUIDException: Attempt to save a configuration entity 'config_error' with UUID 'a23e10dc-f081-4fb5-82c5-5ebe88956d51' when this UUID is already used for 'defining_error_responses_including_403_404_pages' in Drupal\Core\Config\Entity\ConfigEntityBase->preSave() (line 331 of core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php).
Drupal\config_help\Entity\HelpTopic->preSave(Object) (Line: 434)
Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 389)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 259)
...
Proposed resolution
I think this used to work... but it isn't working now. So we should either:
a) Not let people edit the machine name after the entity is first saved
b) Detect that it is changing and make it work somehow
Remaining tasks
Figure out if this is possible, and make it work.
Make a patch with a test.
User interface changes
Depends on the solution decided on, see Proposed Resolution for now.
API changes
Probably not?
Data model changes
No
Comments
Comment #2
jhodgdonUpdate summary and add tag.
Comment #3
jhodgdonThe error is happening in ConfigEntityBase::preSave() from here:
So, it looks like if we set $this->originalId during the editing process, it will work fine.
Hm... it looks like originalId gets set during the constructor in ConfigEntityBase (and not overridden in our entity), so I don't know why this is not working. Except I did notice that setOriginalId(NULL) is called in public function createDuplicate(), so maybe that is the problem. Hmm..
OK, let's see what the editing process does. That is in HelpTopicForm... don't see anything there, let's check the base EntityForm class. It looks like what it does when setting up the entity is a clone of the entity object, followed by some value copying. That should be OK.
Well, I'll do some more debugging...
Comment #5
jhodgdonActually, it looks like this bug has gone away again. I've added a test to make sure it stays gone away.
Comment #6
gnugetGlad that this error is not happening anymore.
Will check the other issue.