From 8018767e9867d48116628df8ed776c88f1d52f8d Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Fri, 9 Jul 2021 07:13:41 +1000 Subject: [PATCH] dev/core#2680 Remove rows in the civicrm_contribution_product table that have bad product_ids in them --- CRM/Upgrade/Incremental/php/FiveForty.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CRM/Upgrade/Incremental/php/FiveForty.php b/CRM/Upgrade/Incremental/php/FiveForty.php index 9a69df5828..0c07adf081 100644 --- a/CRM/Upgrade/Incremental/php/FiveForty.php +++ b/CRM/Upgrade/Incremental/php/FiveForty.php @@ -91,6 +91,8 @@ class CRM_Upgrade_Incremental_php_FiveForty extends CRM_Upgrade_Incremental_Base */ public static function addContributionProductFK(CRM_Queue_TaskContext $ctx): bool { if (!self::checkFKExists('civicrm_contribution_product', 'FK_civicrm_contribution_product_product_id')) { + // dev/core#2680 Clear out any rows with problematic product_ids from the civicrm_contribution_product table. + CRM_Core_DAO::executeQuery("DELETE FROM civicrm_contribution_product WHERE product_id NOT IN (SELECT id FROM civicrm_product)"); CRM_Core_DAO::executeQuery(" ALTER TABLE `civicrm_contribution_product` ADD CONSTRAINT `FK_civicrm_contribution_product_product_id` -- 2.25.1