mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-04-21 18:43:43 +03:00
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:
parent
7847fb546a
commit
d835246f3f
|
@ -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 );
|
||||||
|
|
Loading…
Reference in a new issue