I have upgraded drupal from 9.5 to 10.2.5 and upgraded commerce_shipping to version 2.2.2. Then I am getting an error when I try to checkout:
DrupalCoreEntityEntityStorageException: SQLSTATE[23000]: Integrity constraint
violation: 1062 Duplicate entry '13109' for key 'PRIMARY': INSERT INTO "profile"
("profile_id", "revision_id", "type", "uuid", "status", "uid", "is_default", "data",
"created", "changed") 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); Array (
[:db_insert_placeholder_0] => 13109 [:db_insert_placeholder_1] => 13109
[:db_insert_placeholder_2] => customer [:db_insert_placeholder_3] => cf849757-d6f0-
467a-aa41-dfc4b4489ec7 [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] =>
135275 [:db_insert_placeholder_6] => 1 [:db_insert_placeholder_7] => a:1:
{s:23:"address_book_profile_id";s:5:"13109";} [:db_insert_placeholder_8] =>
1710227063 [:db_insert_placeholder_9] => 1710227063 ) in
DrupalCoreEntitySqlSqlContentEntityStorage->save() (line 817 of
core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
DrupalCoreDatabaseStatementWrapperIterator->execute() (Line: 44)
DrupalmysqlDriverDatabasemysqlInsert->execute() (Line: 948)
DrupalCoreEntitySqlSqlContentEntityStorage->doSaveFieldItems() (Line: 718)
DrupalCoreEntityContentEntityStorageBase->doSave() (Line: 486)
DrupalCoreEntityEntityStorageBase->save() (Line: 806)
DrupalCoreEntitySqlSqlContentEntityStorage->save() (Line: 354)
DrupalCoreEntityEntityBase->save() (Line: 319)
DrupalCoreFieldPluginFieldFieldTypeEntityReferenceItem->preSave() (Line: 263)
Drupalentity_reference_revisionsPluginFieldFieldTypeEntityReferenceRevisionsItem->preSave() (Line: 233)
DrupalCoreFieldFieldItemList->delegateMethod() (Line: 191)
DrupalCoreFieldFieldItemList->preSave() (Line: 938)
DrupalCoreEntityContentEntityStorageBase->invokeFieldMethod() (Line: 888)
DrupalCoreEntityContentEntityStorageBase->invokeHook() (Line: 56)
DrupalcommerceCommerceContentEntityStorage->invokeHook() (Line: 529)
DrupalCoreEntityEntityStorageBase->doPreSave() (Line: 753)
DrupalCoreEntityContentEntityStorageBase->doPreSave() (Line: 483)
DrupalCoreEntityEntityStorageBase->save() (Line: 806)
DrupalCoreEntitySqlSqlContentEntityStorage->save() (Line: 354)
DrupalCoreEntityEntityBase->save() (Line: 55)
Drupalcommerce_shippingLateOrderProcessor->process() (Line: 196)
Drupalcommerce_orderOrderRefresh->refresh() (Line: 123)
Drupalcommerce_orderOrderStorage->doOrderPreSave() (Line: 86)
Drupalcommerce_orderOrderStorage->invokeHook() (Line: 529)
DrupalCoreEntityEntityStorageBase->doPreSave() (Line: 753)
DrupalCoreEntityContentEntityStorageBase->doPreSave() (Line: 483)
DrupalCoreEntityEntityStorageBase->save() (Line: 806)
DrupalCoreEntitySqlSqlContentEntityStorage->save() (Line: 169)
Drupalcommerce_orderOrderStorage->save() (Line: 354)
DrupalCoreEntityEntityBase->save() (Line: 358)
Drupalcommerce_shippingPluginCommerceCheckoutPaneShippingInformation->buildPaneForm() (Line: 546)
Drupalcommerce_checkoutPluginCommerceCheckoutFlowCheckoutFlowWithPanesBase->buildForm()
call_user_func_array() (Line: 536)
DrupalCoreFormFormBuilder->retrieveForm() (Line: 283)
DrupalCoreFormFormBuilder->buildForm() (Line: 224)
DrupalCoreFormFormBuilder->getForm() (Line: 143)
Drupalcommerce_checkoutControllerCheckoutController->formPage()
call_user_func_array() (Line: 123)
DrupalCoreEventSubscriberEarlyRenderingControllerWrapperSubscriber->DrupalCoreEventSubscriber{closure}() (Line: 627)
DrupalCoreRenderRenderer->executeInRenderContext() (Line: 124)
DrupalCoreEventSubscriberEarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
DrupalCoreEventSubscriberEarlyRenderingControllerWrapperSubscriber->DrupalCoreEventSubscriber{closure}() (Line: 181)
SymfonyComponentHttpKernelHttpKernel->handleRaw() (Line: 76)
SymfonyComponentHttpKernelHttpKernel->handle() (Line: 48)
Drupalredirect_after_loginRedirectMiddleware->handle() (Line: 54)
Drupalsimple_oauthHttpMiddlewareBasicAuthSwap->handle() (Line: 58)
DrupalCoreStackMiddlewareSession->handle() (Line: 48)
DrupalCoreStackMiddlewareKernelPreHandle->handle() (Line: 28)
DrupalCoreStackMiddlewareContentLength->handle() (Line: 32)
Drupalbig_pipeStackMiddlewareContentLength->handle() (Line: 106)
Drupalpage_cacheStackMiddlewarePageCache->pass() (Line: 85)
Drupalpage_cacheStackMiddlewarePageCache->handle() (Line: 43)
Drupalwebform_productRedirectMiddleware->handle() (Line: 48)
DrupalCoreStackMiddlewareReverseProxyMiddleware->handle() (Line: 51)
DrupalCoreStackMiddlewareNegotiationMiddleware->handle() (Line: 36)
DrupalCoreStackMiddlewareAjaxPageState->handle() (Line: 51)
DrupalCoreStackMiddlewareStackedHttpKernel->handle() (Line: 704)
DrupalCoreDrupalKernel->handle() (Line: 19)
I found out its happening when order is trying to save shipments in file commerce_shipping/src/Plugin/Commerce/CheckoutPane/ShippingInformation.php –> buildPaneForm line number349
// Update the shipments and save the order if no rate was explicitly
// selected, that usually occurs when changing addresses, this will ensure
// the default rate is selected/applied.
if (!$this->hasRateSelected($pane_form, $form_state) && ($recalculate_shipping || $force_packing)) {
array_map(function (ShipmentInterface $shipment) {
if (!$shipment->isNew()) {
$shipment->save();
}
}, $shipments);
$this->order->set('shipments', $shipments); // this one is causing error.
$this->order->save();
Please help me guys, how I can resolve this issue.