Body: <p>Hi this is one of those really intractable problems which appears to have no obvious cause.</p>
  <p>CiviCRM 5.28.3/Wordpress 5.5 (upgraded from 5.27 today, so unknown if upgrade could resolve problem).</p>
  <p>Attempts to purchase a membership (using PayPal) fail at 'continue to payment' stage. Clicking the button shows the user the 'We cannot provide that at the moment&quot; screen and adds:</p>
  <blockquote>
  <p>Expected one Membership but found 0</p>
  </blockquote>
  <p>The log for a single incidence of this error is 16,000+ lines long! So I'm wondering if there is some sort of infinite loop error going on.</p>
  <p>It's difficult to include a full backtrace with such a vast error entry, and just anonymizing the data would take time. However, here is a brief extract from the start of the log:</p>
  <pre><code>Aug 13 10:42:55  [error]
  $Fatal Error Details = array(3) {
    [&quot;message&quot;]=&gt;
    string(35) &quot;Expected one Membership but found 0&quot;
    [&quot;code&quot;]=&gt;
    NULL
    [&quot;exception&quot;]=&gt;
    object(CiviCRM_API3_Exception)#6479 (8) {
      [&quot;extraParams&quot;:&quot;CiviCRM_API3_Exception&quot;:private]=&gt;
      array(3) {
        [&quot;is_error&quot;]=&gt;
        int(1)
        [&quot;error_message&quot;]=&gt;
        string(35) &quot;Expected one Membership but found 0&quot;
        [&quot;error_code&quot;]=&gt;
        string(9) &quot;undefined&quot;
      }
      [&quot;message&quot;:protected]=&gt;
      string(35) &quot;Expected one Membership but found 0&quot;
      [&quot;string&quot;:&quot;Exception&quot;:private]=&gt;
      string(0) &quot;&quot;
      [&quot;code&quot;:protected]=&gt;
      int(0)
      [&quot;file&quot;:protected]=&gt;
      string(113) &quot;/path/to/website/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Relationship.php&quot;
      [&quot;line&quot;:protected]=&gt;
      int(1062)
      [&quot;trace&quot;:&quot;Exception&quot;:private]=&gt;
      array(25) {
        [0]=&gt;
        array(6) {
          [&quot;file&quot;]=&gt;
          string(114) &quot;/path/to/website/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Contact/Utils.php&quot;
          [&quot;line&quot;]=&gt;
          int(412)
          [&quot;function&quot;]=&gt;
          string(11) &quot;setIsActive&quot;
          [&quot;class&quot;]=&gt;
          string(28) &quot;CRM_Contact_BAO_Relationship&quot;
          [&quot;type&quot;]=&gt;
          string(2) &quot;::&quot;
          [&quot;args&quot;]=&gt;
          array(2) {
            [0]=&gt;
            string(4) &quot;1239&quot;
            [1]=&gt;
            bool(false)
          }
        }
        [1]=&gt;
        array(6) {
          [&quot;file&quot;]=&gt;
          string(114) &quot;/path/to/website/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Contact/Utils.php&quot;
          [&quot;line&quot;]=&gt;
          int(290)
          [&quot;function&quot;]=&gt;
          string(20) &quot;clearCurrentEmployer&quot;
          [&quot;class&quot;]=&gt;
          string(29) &quot;CRM_Contact_BAO_Contact_Utils&quot;
          [&quot;type&quot;]=&gt;
          string(2) &quot;::&quot;
          [&quot;args&quot;]=&gt;
          array(2) {
            [0]=&gt;
            string(4) &quot;3579&quot;
            [1]=&gt;
            string(4) &quot;1849&quot;
          }
        }
        [2]=&gt;
        array(6) {
          [&quot;file&quot;]=&gt;
          string(108) &quot;/path/to/website/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Contact.php&quot;
          [&quot;line&quot;]=&gt;
          int(203)
          [&quot;function&quot;]=&gt;
          string(33) &quot;createCurrentEmployerRelationship&quot;
          [&quot;class&quot;]=&gt;
          string(29) &quot;CRM_Contact_BAO_Contact_Utils&quot;
          [&quot;type&quot;]=&gt;
          string(2) &quot;::&quot;
          [&quot;args&quot;]=&gt;
          array(4) {
            [0]=&gt;
            string(4) &quot;3579&quot;
            [1]=&gt;
            string(4) &quot;8194&quot;
            [2]=&gt;
            string(4) &quot;1849&quot;
            [3]=&gt;
            bool(false)
          }
        }
        [3]=&gt;
        array(6) {
          [&quot;file&quot;]=&gt;
          string(108) &quot;/path/to/website/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Contact.php&quot;
          [&quot;line&quot;]=&gt;
          int(290)
          [&quot;function&quot;]=&gt;
          string(3) &quot;add&quot;
          [&quot;class&quot;]=&gt;
          string(23) &quot;CRM_Contact_BAO_Contact&quot;
          [&quot;type&quot;]=&gt;
          string(2) &quot;::&quot;
          [&quot;args&quot;]=&gt;
          array(1) {
            [0]=&gt;
            &amp;array(35) {
              [&quot;source&quot;]=&gt;
              NULL
              [&quot;contact_type&quot;]=&gt;
              string(10) &quot;Individual&quot;
              [&quot;contact_sub_type&quot;]=&gt;
              NULL
              [&quot;contact_id&quot;]=&gt;
              string(4) &quot;3579&quot;
              [&quot;qfKey&quot;]=&gt;
              string(35) &quot;ab6ab1bff51cb50fdb2476be3c8d8359_53&quot;
              [&quot;entryURL&quot;]=&gt;
              string(78) &quot;https://example.com/join/?civiwp=CiviCRM&amp;amp;q=civicrm%2Fcontribute%2Ftransact&quot;
              [&quot;first_name&quot;]=&gt;
              string(5) &quot;Tracy&quot;
              [&quot;last_name&quot;]=&gt;
              string(6) &quot;Hussey&quot;
              [&quot;current_employer&quot;]=&gt;
              string(23) &quot;Trumpton Fire Station&quot;
              [&quot;job_title&quot;]=&gt;
              string(18) &quot;Executive Director&quot;
              [&quot;email&quot;]=&gt;
              array(2) {
                [1]=&gt;
                array(3) {
                  [&quot;location_type_id&quot;]=&gt;
                  string(1) &quot;2&quot;
                  [&quot;is_primary&quot;]=&gt;
                  int(1)
                  [&quot;email&quot;]=&gt;
                  string(31) &quot;example@example.com&quot;
                }
                [3]=&gt;
                array(3) {
                  [&quot;location_type_id&quot;]=&gt;
                  string(1) &quot;5&quot;
                  [&quot;is_billing&quot;]=&gt;
                  int(1)
                  [&quot;email&quot;]=&gt;
                  string(31) &quot;example@example.com&quot;
                }
              }
              [&quot;phone&quot;]=&gt;
              array(1) {
                [2]=&gt;
                array(4) {
                  [&quot;location_type_id&quot;]=&gt;
                  string(1) &quot;2&quot;
                  [&quot;is_primary&quot;]=&gt;
                  int(1)
                  [&quot;phone_type_id&quot;]=&gt;
                  string(1) &quot;1&quot;
                  [&quot;phone&quot;]=&gt;
                  string(10) &quot;5555555555&quot;
                }
              }
              [&quot;address&quot;]=&gt;
              array(1) {
                [1]=&gt;
                array(5) {
                  [&quot;location_type_id&quot;]=&gt;
                  string(1) &quot;2&quot;
                  [&quot;is_primary&quot;]=&gt;
                  int(1)
                  [&quot;city&quot;]=&gt;
                  string(10) &quot;Trumpton&quot;
                  [&quot;state_province_id&quot;]=&gt;
                  string(4) &quot;1108&quot;
                  [&quot;country_id&quot;]=&gt;
                  string(4) &quot;1039&quot;
                }
              }
              [&quot;onbehalf&quot;]=&gt;
              array(8) {
                [&quot;organization_name&quot;]=&gt;
                string(23) &quot;Trumpton Fire Station&quot;
                [&quot;phone-3-1&quot;]=&gt;
                string(10) &quot;6666666666&quot;
                [&quot;email-3&quot;]=&gt;
                string(29) &quot;example@example.com&quot;
                [&quot;street_address-3&quot;]=&gt;
                string(31) &quot;123 Chigley Street&quot;
                [&quot;city-3&quot;]=&gt;
                string(10) &quot;Trumpton&quot;
                [&quot;postal_code-3&quot;]=&gt;
                string(7) &quot;1A1A1A&quot;
                [&quot;state_province-3&quot;]=&gt;
                string(4) &quot;1108&quot;
                [&quot;country-3&quot;]=&gt;
                string(4) &quot;1039&quot;
              }
              [&quot;hidden_processor&quot;]=&gt;
              string(1) &quot;1&quot;
              [&quot;payment_processor_id&quot;]=&gt;
              string(1) &quot;5&quot;
              [&quot;priceSetId&quot;]=&gt;
              string(3) &quot;164&quot;
              [&quot;price_64&quot;]=&gt;
              string(3) &quot;103&quot;
              [&quot;selectProduct&quot;]=&gt;
              string(0) &quot;&quot;
              [&quot;MAX_FILE_SIZE&quot;]=&gt;
              string(8) &quot;20971520&quot;
              [&quot;ip_address&quot;]=&gt;
              string(11) &quot;0.0.0.0&quot;
              [&quot;amount&quot;]=&gt;
              float(180)
              [&quot;tax_amount&quot;]=&gt;
              NULL
              [&quot;currencyID&quot;]=&gt;
              string(3) &quot;CAD&quot;
              [&quot;selectMembership&quot;]=&gt;
              NULL
              [&quot;is_pay_later&quot;]=&gt;
              int(0)
              [&quot;invoiceID&quot;]=&gt;
              string(32) &quot;53d78c803925d95bc576e06481e33943&quot;
              [&quot;description&quot;]=&gt;
              string(91) &quot;OOnline&quot;
              [&quot;accountingCode&quot;]=&gt;
              NULL
              [&quot;updateBlankLocInfo&quot;]=&gt;
              bool(false)
              [&quot;email_greeting_id&quot;]=&gt;
              string(1) &quot;1&quot;
              [&quot;postal_greeting_id&quot;]=&gt;
              string(1) &quot;1&quot;
              [&quot;addressee_id&quot;]=&gt;
              string(1) &quot;1&quot;
              [&quot;addressee_custom&quot;]=&gt;
              string(18) &quot;Executive Director&quot;
              [&quot;is_deceased&quot;]=&gt;
              bool(false)
            }
          }
        }
  </code></pre>
  <p>I'd very much appreciate any suggestions as to what might be going on. This is a longstanding website and this is a new problem arising in the last few days.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-08-23T23:12:31.160Z
Comments.Text: so this problem preceded the civi upgrade?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-08-24T00:34:41.093Z
Comments.Text: The question from @petednz-fuzion is crucial - I believe there was a bug in 5.27.x that replaced Null with '0' in some places and caused some issues: this could be related to that? In which case upgrading to 5.28.3 should have fixed it.
Comments.UserDisplayName: Hugh
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-08-24T17:28:22.473Z
Comments.Text: @petednz-fuzion Thanks - yes it did precede the upgrade. Ok, that gives me some hope that the problem may go away. Time will tell.
Comments.UserDisplayName: fred2
Tags: <civicontribute><civimember><error>
Title: "Expected one membership but found 0": Frequent but intermittent membership/contribution errors
ThreadText: # "Expected one membership but found 0": Frequent but intermittent membership/contribution errors
  
  (Asked by: username_0 on 2020-08-22)
  
  Hi this is one of those really intractable problems which appears to have no obvious cause.
  CiviCRM 5.28.3/Wordpress 5.5 (upgraded from 5.27 today, so unknown if upgrade could resolve problem).
  Attempts to purchase a membership (using PayPal) fail at 'continue to payment' stage. Clicking the button shows the user the 'We cannot provide that at the moment" screen and adds:
  
  Expected one Membership but found 0
  
  The log for a single incidence of this error is 16,000+ lines long! So I'm wondering if there is some sort of infinite loop error going on.
  It's difficult to include a full backtrace with such a vast error entry, and just anonymizing the data would take time. However, here is a brief extract from the start of the log:
  Aug 13 10:42:55  [error]
  $Fatal Error Details = array(3) {
    ["message"]=>
    string(35) "Expected one Membership but found 0"
    ["code"]=>
    NULL
    ["exception"]=>
    object(CiviCRM_API3_Exception)#6479 (8) {
      ["extraParams":"CiviCRM_API3_Exception":private]=>
      array(3) {
        ["is_error"]=>
        int(1)
        ["error_message"]=>
        string(35) "Expected one Membership but found 0"
        ["error_code"]=>
        string(9) "undefined"
      }
      ["message":protected]=>
      string(35) "Expected one Membership but found 0"
      ["string":"Exception":private]=>
      string(0) ""
      ["code":protected]=>
      int(0)
      ["file":protected]=>
      string(113) "/path/to/website/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Relationship.php"
      ["line":protected]=>
      int(1062)
      ["trace":"Exception":private]=>
      array(25) {
        [0]=>
        array(6) {
          ["file"]=>
          string(114) "/path/to/website/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Contact/Utils.php"
          ["line"]=>
          int(412)
          ["function"]=>
          string(11) "setIsActive"
          ["class"]=>
          string(28) "CRM_Contact_BAO_Relationship"
          ["type"]=>
          string(2) "::"
          ["args"]=>
          array(2) {
            [0]=>
            string(4) "1239"
            [1]=>
            bool(false)
          }
        }
        [1]=>
        array(6) {
          ["file"]=>
          string(114) "/path/to/website/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Contact/Utils.php"
          ["line"]=>
          int(290)
          ["function"]=>
          string(20) "clearCurrentEmployer"
          ["class"]=>
          string(29) "CRM_Contact_BAO_Contact_Utils"
          ["type"]=>
          string(2) "::"
          ["args"]=>
          array(2) {
            [0]=>
            string(4) "3579"
            [1]=>
            string(4) "1849"
          }
        }
        [2]=>
        array(6) {
          ["file"]=>
          string(108) "/path/to/website/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Contact.php"
          ["line"]=>
          int(203)
          ["function"]=>
          string(33) "createCurrentEmployerRelationship"
          ["class"]=>
          string(29) "CRM_Contact_BAO_Contact_Utils"
          ["type"]=>
          string(2) "::"
          ["args"]=>
          array(4) {
            [0]=>
            string(4) "3579"
            [1]=>
            string(4) "8194"
            [2]=>
            string(4) "1849"
            [3]=>
            bool(false)
          }
        }
        [3]=>
        array(6) {
          ["file"]=>
          string(108) "/path/to/website/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Contact.php"
          ["line"]=>
          int(290)
          ["function"]=>
          string(3) "add"
          ["class"]=>
          string(23) "CRM_Contact_BAO_Contact"
          ["type"]=>
          string(2) "::"
          ["args"]=>
          array(1) {
            [0]=>
            &array(35) {
              ["source"]=>
              NULL
              ["contact_type"]=>
              string(10) "Individual"
              ["contact_sub_type"]=>
              NULL
              ["contact_id"]=>
              string(4) "3579"
              ["qfKey"]=>
              string(35) "ab6ab1bff51cb50fdb2476be3c8d8359_53"
              ["entryURL"]=>
              string(78) "https://example.com/join/?civiwp=CiviCRM&q=civicrm%2Fcontribute%2Ftransact"
              ["first_name"]=>
              string(5) "Tracy"
              ["last_name"]=>
              string(6) "Hussey"
              ["current_employer"]=>
              string(23) "Trumpton Fire Station"
              ["job_title"]=>
              string(18) "Executive Director"
              ["email"]=>
              array(2) {
                [1]=>
                array(3) {
                  ["location_type_id"]=>
                  string(1) "2"
                  ["is_primary"]=>
                  int(1)
                  ["email"]=>
                  string(31) "example@example.com"
                }
                [3]=>
                array(3) {
                  ["location_type_id"]=>
                  string(1) "5"
                  ["is_billing"]=>
                  int(1)
                  ["email"]=>
                  string(31) "example@example.com"
                }
              }
              ["phone"]=>
              array(1) {
                [2]=>
                array(4) {
                  ["location_type_id"]=>
                  string(1) "2"
                  ["is_primary"]=>
                  int(1)
                  ["phone_type_id"]=>
                  string(1) "1"
                  ["phone"]=>
                  string(10) "5555555555"
                }
              }
              ["address"]=>
              array(1) {
                [1]=>
                array(5) {
                  ["location_type_id"]=>
                  string(1) "2"
                  ["is_primary"]=>
                  int(1)
                  ["city"]=>
                  string(10) "Trumpton"
                  ["state_province_id"]=>
                  string(4) "1108"
                  ["country_id"]=>
                  string(4) "1039"
                }
              }
              ["onbehalf"]=>
              array(8) {
                ["organization_name"]=>
                string(23) "Trumpton Fire Station"
                ["phone-3-1"]=>
                string(10) "6666666666"
                ["email-3"]=>
                string(29) "example@example.com"
                ["street_address-3"]=>
                string(31) "123 Chigley Street"
                ["city-3"]=>
                string(10) "Trumpton"
                ["postal_code-3"]=>
                string(7) "1A1A1A"
                ["state_province-3"]=>
                string(4) "1108"
                ["country-3"]=>
                string(4) "1039"
              }
              ["hidden_processor"]=>
              string(1) "1"
              ["payment_processor_id"]=>
              string(1) "5"
              ["priceSetId"]=>
              string(3) "164"
              ["price_64"]=>
              string(3) "103"
              ["selectProduct"]=>
              string(0) ""
              ["MAX_FILE_SIZE"]=>
              string(8) "20971520"
              ["ip_address"]=>
              string(11) "0.0.0.0"
              ["amount"]=>
              float(180)
              ["tax_amount"]=>
              NULL
              ["currencyID"]=>
              string(3) "CAD"
              ["selectMembership"]=>
              NULL
              ["is_pay_later"]=>
              int(0)
              ["invoiceID"]=>
              string(32) "53d78c803925d95bc576e06481e33943"
              ["description"]=>
              string(91) "OOnline"
              ["accountingCode"]=>
              NULL
              ["updateBlankLocInfo"]=>
              bool(false)
              ["email_greeting_id"]=>
              string(1) "1"
              ["postal_greeting_id"]=>
              string(1) "1"
              ["addressee_id"]=>
              string(1) "1"
              ["addressee_custom"]=>
              string(18) "Executive Director"
              ["is_deceased"]=>
              bool(false)
            }
          }
        }
  
  I'd very much appreciate any suggestions as to what might be going on. This is a longstanding website and this is a new problem arising in the last few days.
  
  **Tags:** civicontribute, civimember, error
  
  > **Comments:**
  > **username_1**: so this problem preceded the civi upgrade?  
  > **username_2**: The question from @petednz-fuzion is crucial - I believe there was a bug in 5.27.x that replaced Null with '0' in some places and caused some issues: this could be related to that? In which case upgrading to 5.28.3 should have fixed it.  
  > **username_0**: @petednz-fuzion Thanks - yes it did precede the upgrade. Ok, that gives me some hope that the problem may go away. Time will tell.  
  
  ---
  
  ## 0 answers
  
  