Problem/Motivation
When attempting to write values to the loc column that are greater than 256 characters long, a DatabaseExceptionWrapper exception.
Proposed resolution
Increase the loc
field to support longer locations, or at a minimum, catch the exception so the sitemap can still be built (albeit missing the entry that is too long).
Remaining tasks
Write Patch- Review Patch
User interface changes
None.
API changes
None.
Data model changes
Loc column lenght extended to 512.
Original Report
Everytime I try and build the sitemap for the first time, I get this error:
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'loc' at row 1: INSERT INTO {xmlsitemap} (type, id, loc, subtype, access, status, status_override, lastmod, priority, priority_override, changefreq, changecount, language) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12); Array ( [:db_insert_placeholder_0] => file [:db_insert_placeholder_1] => 1085411 [:db_insert_placeholder_2] => https://example.com/sites/default/files/video/thumbnail/1430780407.984--1070.373c1430781645.042--804.037c1430782570.534--19.42c1430782742.072--396.964c1430783321.252--242.409c1430783686.717--24.491c1430783862.493--672.305_1280x720_439541315986.mp4 [:db_insert_placeholder_3] => file [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => 0 [:db_insert_placeholder_6] => 0 [:db_insert_placeholder_7] => 1430788801 [:db_insert_placeholder_8] => 0.5 [:db_insert_placeholder_9] => 0 [:db_insert_placeholder_10] => 0 [:db_insert_placeholder_11] => 0 [:db_insert_placeholder_12] => en ) in Drupal\xmlsitemap\XmlSitemapLinkStorage->save() (line 138 of modules/contrib/xmlsitemap/src/XmlSitemapLinkStorage.php).
Drupal\Core\Database\Statement->execute(Array, Array) (Line: 615)
Drupal\Core\Database\Connection->query('INSERT INTO {xmlsitemap} (type, id, loc, subtype, access, status, status_override, lastmod, priority, priority_override, changefreq, changecount, language) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12)', Array, Array) (Line: 86)
Drupal\Core\Database\Driver\mysql\Connection->query('INSERT INTO {xmlsitemap} (type, id, loc, subtype, access, status, status_override, lastmod, priority, priority_override, changefreq, changecount, language) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12)', Array, Array) (Line: 37)
Drupal\Core\Database\Driver\mysql\Insert->execute() (Line: 376)
Drupal\Core\Database\Query\Merge->execute() (Line: 138)
Drupal\xmlsitemap\XmlSitemapLinkStorage->save(Array) (Line: 1582)
xmlsitemap_xmlsitemap_process_entity_links('file', Array) (Line: 2549)
xmlsitemap_rebuild_batch_fetch('file', Array)
call_user_func_array('xmlsitemap_rebuild_batch_fetch', Array) (Line: 252)
_batch_process(Array) (Line: 144)
_batch_progress_page() (Line: 72)
_batch_page(Object) (Line: 60)
Drupal\system\Controller\BatchController->batchPage(Object)
call_user_func_array(Array, Array) (Line: 128)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 577)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 129)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 102)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 139)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 62)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 55)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 31)
Drupal\gc_api\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 637)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)