When a pledge has no contributors, return zero contributors/hours

This avoids a PHP Notice during the cron task to update the contributor/hour counters.

By returning 0 here we have "valid" metadata attached to the pledge posts, which removes the need for further logic there.

Closes #151
This commit is contained in:
Dion Hulse 2020-10-07 13:46:00 +10:00 committed by GitHub
parent 7847fb546a
commit d835246f3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,14 +48,18 @@ function get_xprofile_contribution_data( array $user_ids ) {
* *
* @param int $pledge_id * @param int $pledge_id
* *
* @return array|false * @return array
*/ */
function get_aggregate_contributor_data_for_pledge( $pledge_id ) { function get_aggregate_contributor_data_for_pledge( $pledge_id ) {
$contributor_posts = Contributor\get_pledge_contributors( $pledge_id, 'publish' ); $contributor_posts = Contributor\get_pledge_contributors( $pledge_id, 'publish' );
// All of their contributors might have declined the invitation and had their posts deleted. // All of their contributors might have declined the invitation and had their posts deleted.
if ( ! $contributor_posts ) { if ( ! $contributor_posts ) {
return false; return array(
'contributors' => 0,
'hours' => 0,
'teams' => array(),
);
} }
$contributor_users = Contributor\get_contributor_user_objects( $contributor_posts ); $contributor_users = Contributor\get_contributor_user_objects( $contributor_posts );