I enabled the language module on my site, and then went to go update the sitemap to the default language.

The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Core\Config\ConfigDuplicateUUIDException</em>: Attempt to save a configuration entity &#039;g3XYqcXbSKPVBDODwnT6pq7oqhCFkPryj4vVqrl_Kfc&#039; with UUID &#039;1af1b0e9-db49-453d-a439-918683b1402b&#039; when this UUID is already used for &#039;NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM&#039; in <em class="placeholder">Drupal\Core\Config\Entity\ConfigEntityBase-&gt;preSave()</em> (line <em class="placeholder">326</em> of <em class="placeholder">core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php</em>). <pre class="backtrace">Drupal\Core\Entity\EntityStorageBase-&gt;doPreSave(Object) (Line: 426)
Drupal\Core\Entity\EntityStorageBase-&gt;save(Object) (Line: 263)
Drupal\Core\Config\Entity\ConfigEntityStorage-&gt;save(Object) (Line: 390)
Drupal\Core\Entity\Entity-&gt;save() (Line: 632)
Drupal\Core\Config\Entity\ConfigEntityBase-&gt;save() (Line: 75)
Drupal\xmlsitemap\Form\XmlSitemapForm-&gt;save(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter-&gt;executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter-&gt;doSubmitForm(Array, Object) (Line: 589)
Drupal\Core\Form\FormBuilder-&gt;processForm(&#039;xmlsitemap_sitemap_edit_form&#039;, Array, Object) (Line: 318)
Drupal\Core\Form\FormBuilder-&gt;buildForm(&#039;xmlsitemap_sitemap_edit_form&#039;, Object) (Line: 93)
Drupal\Core\Controller\FormController-&gt;getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 665)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)
</pre>

Comments

Dave Reid created an issue. See original summary.

dave reid’s picture

I think the solution is to make the config ID a machine name, and have the context hash be a separate property on the config entity. That way we can freely change it when needed.

KittenDestroyer’s picture

Status: Active » Needs review
StatusFileSize
new2.1 KB

Adding a patch for that. Please review as it will probably need improvement.

KittenDestroyer’s picture

StatusFileSize
new2.55 KB
KittenDestroyer’s picture

StatusFileSize
new4.06 KB

Added missing exists method. Added context id to list builder and check on save.

KittenDestroyer’s picture

StatusFileSize
new5.45 KB

Updated list builder test and fixed fails on my side.

niko-’s picture

updated patch for latest d9

niko-’s picture

StatusFileSize
new3.34 KB

Reroll last patch

Status: Needs review » Needs work

The last submitted patch, 8: 3006298-updating-sitemap-language-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

xurizaemon’s picture

Some sites affected by this issue may already have a config state which requires resolution here.

A common configuration appears to be:

  • A default xmlsitemap entry was created at install with some default name and context = [] (hash NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM)
  • After some configuration, a second entry was created with the same name and different context, eg context=['language' => 'en'] (hash g3XYqcXbSKPVBDODwnT6pq7oqhCFkPryj4vVqrl_Kfc).

If the patch here is then applied, the update process to try and resolve this state fails when two entries are resolved to a single machine name, and the DB update fails when trying to write the second one.

>  [notice] Update started: xmlsitemap_update_8004
>  [error]  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'xmlsitemap.xmlsitemap.sector_default_sitemap' for key 'config.PRIMARY': UPDATE "config" SET "name"=:db_update_placeholder_0
> WHERE ("name" = :db_condition_placeholder_0) AND ("collection" = :db_condition_placeholder_1); Array
> (
>     [:db_update_placeholder_0] => xmlsitemap.xmlsitemap.sector_default_sitemap
>     [:db_condition_placeholder_0] => xmlsitemap.xmlsitemap.NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM
>     [:db_condition_placeholder_1] => 
> )
>  
>  [error]  Update failed: xmlsitemap_update_8004 
 [error]  Update aborted by: xmlsitemap_update_8004 
 [error]  Finished performing updates. 

("Sector default sitemap" is the default name from Sector profile, and it installs with language module disabled and hash NXhscRe0440PFpI5dSznEVgmauL25KojD7u4e9aZwOM.)

xurizaemon’s picture

Ah, it seems that issue is because sites which install from existing configuration don't have xmlsitemap_update_8004() applied, which makes sense.