Sitemap cannot be generated from valid raw XML if any <url> elements contain a <priority> value

Created on 20 June 2025, about 2 months ago

Problem/Motivation

A sitemap of "Super Sitemap External XML" type cannot be generated if any of the data sources contain elements with a
value.

This is the error returned:

Exception: Serialization of 'SimpleXMLElement' is not allowed in serialize() (line 132 of modules/contrib/simple_sitemap/src/Queue/SimpleSitemapQueue.php). Drupal\simple_sitemap\Queue\SimpleSitemapQueue->doCreateItems(Array) (Line: 109)
Drupal\simple_sitemap\Queue\SimpleSitemapQueue->createItems(Array) (Line: 250)
Drupal\simple_sitemap\Queue\QueueWorker->queueElements(Array) (Line: 207)
Drupal\simple_sitemap\Queue\QueueWorker->queue(Array) (Line: 235)
Drupal\simple_sitemap\Queue\QueueWorker->rebuildQueue(Array) (Line: 104)
Drupal\super_sitemap\Queue\QueueWorkerOverrider->generate() (Line: 88)
Drupal\simple_sitemap\Queue\QueueWorker::doBatchGenerate(Array) (Line: 297)
_batch_process() (Line: 139)
_batch_do() (Line: 95)
_batch_page(Object) (Line: 52)
Drupal\system\Controller\BatchController->batchPage(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

1. Create a new data source (/admin/config/search/simplesitemap/super-extras/data-sources/add).
2. Fill in a "Label" and select a "Sitemap" to include this data source in.
3. Under the "XML source" field, paste in valid sitemap XML markup where at least one element contains a
value - e.g.,

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/sitemap_generator/default/sitemap.xsl"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
 <url>
  <loc>https://dxp-cphb-preview-212.apps.int.drop.preprod.us-east-1.aws.paas.redhat.com/recognition</loc>
  <lastmod>2023-09-25T11:29:39+00:00</lastmod>
  <changefreq>monthly</changefreq>
  <priority>1.0</priority>
 </url>
 <url>
  <loc>https://dxp-cphb-preview-212.apps.int.drop.preprod.us-east-1.aws.paas.redhat.com/help/legal</loc>
  <lastmod>2023-06-16T15:52:44+00:00</lastmod>
  <changefreq>monthly</changefreq>
  <priority>1.0</priority>
 </url>
</urlset>

4. Save.
5. Go to /admin/config/search/simplesitemap and click "Rebuild queue & generate".
6. You will see the error:

Exception: Serialization of 'SimpleXMLElement' is not allowed in serialize() (line 132 of modules/contrib/simple_sitemap/src/Queue/SimpleSitemapQueue.php).

Proposed resolution

* Remove the setting of the `
` value in `SuperXmlDataSourceUrlGenerator.php`. According to Google, it ignores `
` values (reference).

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States edwardchiapet New York, NY

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024