StripeCustomer.updatecontactids fails when customer id is null
Not sure why but for a client site of ours, the civicrm_stripe_customers has quite a few rows with 'id IS NULL', which means that when we get here: https://lab.civicrm.org/extensions/stripe/blob/master/api/v3/StripeCustomer.php#L181
we get a message along the lines of.
Nov 26 19:45:08 [info] $Fatal Error Details = Array
(
[message] => is not of type String
[code] =>
)
I'm not sure what the correct thing to do is when you have rows with 'id IS NULL' in the civicrm_stripe_customers table (your thoughts welcome) but in the interests of making the upgrader a bit more robust, I did the following
index 4a2a67fd..63af912a 100644
--- a/src/wp-content/civicrm-extensions/stripe/api/v3/StripeCustomer.php
+++ b/src/wp-content/civicrm-extensions/stripe/api/v3/StripeCustomer.php
@@ -168,7 +168,7 @@ function civicrm_api3_stripe_customer_updatecontactids($params) {
}
catch (Exception $e) {
// Most common problem is duplicates.
- if(preg_match("/Expected one Contact but found/", $e->getMessage())) {
+ if(preg_match("/Expected one Contact but found/", $e->getMessage()) && $dao->id) {
// If we find more than one, first try to find it via a related subscription record
// using the customer id.
$sql = "SELECT c.id
May well be that this is just weird one offness with this client but I can't see how this extra check would hurt anyone.