Making WordPress.org


Ignore:
Timestamp:
04/01/2022 03:30:53 AM (3 years ago)
Author:
dd32
Message:

Plugin Directory: Stats Report: Fix the first request to the HelpScout API endpoints.

  • The first non-cached request to the HelpScout API failed to use the proper Authorization header format, due to a missing BEARER prefix.
  • Increased the API timeout for HelpScout to 15s, although it probably doesn't need it.
  • Make it more obvious that something is wrong with the HelpScout details, by returning 0's for all numbers, rather than just one or two of them.

See #4306.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-stats-report.php

    r11726 r11728  
    171171        $email_report    = HelpScout::api( '/v2/reports/email', $api_payload );
    172172
     173        // If any of the API's are unavailable, make it obvious that the requests have failed, but returning 0's for everything.
     174        if ( ! $company_report || ! $mailbox_overall || ! $email_report ) {
     175            $company_report = $mailbox_overall = $email_report = false;
     176        }
     177
    173178        $stats['helpscout_queue_total_conversations']     = $mailbox_overall->current->totalConversations ?? 0;
    174179        $stats['helpscout_queue_new_conversations']       = $mailbox_overall->current->newConversations ?? 0;
    175180        $stats['helpscout_queue_customers']               = $mailbox_overall->current->customers ?? 0;
    176181        $stats['helpscout_queue_conversations_per_day']   = $mailbox_overall->current->conversationsPerDay ?? 0;
    177         $stats['helpscout_queue_busiest_day']             = gmdate( 'l', strtotime( 'Sunday +' . $mailbox_overall->busiestDay->day . ' days' ) ); // Hacky? but works
     182        $stats['helpscout_queue_busiest_day']             = gmdate( 'l', strtotime( 'Sunday +' . ( $mailbox_overall->busiestDay->day ?? 0 ) . ' days' ) ); // Hacky? but works
    178183        $stats['helpscout_queue_messages_received']       = $mailbox_overall->current->messagesReceived ?? 0;
    179184        $stats['helpscout_queue_replies_sent']            = $company_report->current->totalReplies;
Note: See TracChangeset for help on using the changeset viewer.