Ejegg has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/394629 )
Change subject: Debugging for mystery FK errors
......................................................................
Debugging for mystery FK errors
Change-Id: I29da014cc25bac75540d84f94e68e5cbe19ea0c0
---
M sites/all/modules/wmf_civicrm/wmf_civicrm.module
M sites/all/modules/wmf_common/WmfDatabase.php
2 files changed, 27 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm
refs/changes/29/394629/1
diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
index 0f1961e..058c8a4 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.module
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.module
@@ -1193,6 +1193,9 @@
}
}
+ if (WmfDatabase::isNativeTxnRolledBack()) {
+ throw new WmfException("IMPORT_CONTACT", "Native txn rolled back before
inserting contact");
+ }
// Attempt to insert the contact
try {
$contact_result = civicrm_api3( "Contact", "Create", $contact );
@@ -1201,6 +1204,10 @@
} else {
watchdog( 'wmf_civicrm', 'Result for updating contact: %contact',
array( '%contact' => print_r( $contact_result, true )), WATCHDOG_DEBUG );
}
+
+ if (WmfDatabase::isNativeTxnRolledBack()) {
+ throw new WmfException("IMPORT_CONTACT", "Native txn rolled back after
inserting contact");
+ }
} catch ( CiviCRM_API3_Exception $ex ) {
throw new WmfException(
"IMPORT_CONTACT",
@@ -1297,7 +1304,9 @@
throw new WmfException( 'IMPORT_CONTACT', $ex->getMessage() );
}
}
-
+ if (WmfDatabase::isNativeTxnRolledBack()) {
+ throw new WmfException("IMPORT_CONTACT", "Native txn rolled back after
inserting contact auxiliary fields");
+ }
return $contact_result;
}
@@ -1433,6 +1442,9 @@
*/
function wmf_civicrm_message_location_insert( $msg, $contact ) {
wmf_civicrm_message_email_insert( $msg, $contact[ 'id' ] );
+ if (WmfDatabase::isNativeTxnRolledBack()) {
+ throw new WmfException("IMPORT_CONTACT", "Native txn rolled back after
inserting email");
+ }
wmf_civicrm_message_address_insert( $msg, $contact[ 'id' ] );
}
@@ -1644,7 +1656,9 @@
if (!wmf_civicrm_is_address_valid($address_params)) {
return;
}
-
+ if (WmfDatabase::isNativeTxnRolledBack()) {
+ throw new WmfException("IMPORT_CONTACT", "Native txn rolled back before
inserting address");
+ }
try {
civicrm_api3('Address', 'Create', $address_params);
}
@@ -1655,6 +1669,10 @@
$ex->getMessage()
);
}
+
+ if (WmfDatabase::isNativeTxnRolledBack()) {
+ throw new WmfException("IMPORT_CONTACT", "Native txn rolled back after
inserting address");
+ }
}
function wmf_civicrm_get_default_location_type_id() {
diff --git a/sites/all/modules/wmf_common/WmfDatabase.php
b/sites/all/modules/wmf_common/WmfDatabase.php
index d52dddf..13e5783 100644
--- a/sites/all/modules/wmf_common/WmfDatabase.php
+++ b/sites/all/modules/wmf_common/WmfDatabase.php
@@ -1,6 +1,8 @@
<?php
//TODO: namespace
+use Civi\Core\Transaction\Manager;
+
class WmfDatabase {
/**
* Multiple-database transaction around your callback.
@@ -27,7 +29,7 @@
// Detect if anything has marked the native Civi transaction for
// rollback, and do not proceed if so.
- if
(\Civi\Core\Transaction\Manager::singleton()->getFrame()->isRollbackOnly()) {
+ if (self::isNativeTxnRolledBack()) {
throw new RuntimeException(
'Civi Transaction was marked for rollback and Exception
was suppressed'
);
@@ -48,4 +50,8 @@
unset( $drupal_transaction );
return $result;
}
+
+ public static function isNativeTxnRolledBack() {
+ return Manager::singleton()->getFrame()->isRollbackOnly();
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/394629
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I29da014cc25bac75540d84f94e68e5cbe19ea0c0
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits