Skip to content

Commit

Permalink
QBO: Only access ID for successful responses to avoid fatal error
Browse files Browse the repository at this point in the history
ba7fa61 refactored this function, but accidentally started accessing the `Id` field before checking if the response was a `WP_Error`. That triggers a fatal error because it's treating an object like an array.
  • Loading branch information
iandunn authored and renintw committed Sep 11, 2023
1 parent 57073be commit 94985a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions public_html/wp-content/plugins/wordcamp-qbo/wordcamp-qbo.php
Original file line number Diff line number Diff line change
Expand Up @@ -750,12 +750,12 @@ protected static function notify_invoice_failed_to_send( $invoice_id, $error ) {
* @return int|WP_Error The customer ID if success; a WP_Error if failure
*/
protected static function probably_get_customer_id( $sponsor, $currency_code ) {
$customer = self::get_customer( $sponsor['company-name'], $currency_code );
$customer_id = $customer['Id'];
$customer = self::get_customer( $sponsor['company-name'], $currency_code );

if ( is_wp_error( $customer ) || ! $customer ) {
$customer_id = self::create_customer( $sponsor, $currency_code );
} else {
$customer_id = $customer['Id'];
self::update_customer( $customer, $sponsor );
}

Expand Down

0 comments on commit 94985a9

Please sign in to comment.