Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined index: total_spent when no Customer exists #8128

Closed
mihaijoldis opened this issue Sep 29, 2020 · 1 comment · Fixed by #8140
Closed

Undefined index: total_spent when no Customer exists #8128

mihaijoldis opened this issue Sep 29, 2020 · 1 comment · Fixed by #8140
Assignees
Labels
Milestone

Comments

@mihaijoldis
Copy link
Contributor

Bug Report

Expected behavior

to not have any notices in the error logs

Actual behavior

Customer reports:
Since your last plugin update the bug below shows up in your logs. Could you have a look at this bug:
[29-Sep-2020 10:28:31 UTC] PHP Notice: Undefined index: total_spent in /home/redacted/public_html/wp-content/plugins/easy-digital-downloads/includes/user-functions.php on line 353

Steps to reproduce the behavior

I was able to replicate this via the Debug Bar console by running the code below but i deleted the EDD Customer record before running it.

<?php
	$stats = edd_get_purchase_stats_by_user( 2 );

	print $stats['total_spent'];

Information (if a specific version is affected):

PHP Version:

EDD Version (or branch): 2.9.25

WordPress Version: latest

Any other relevant information:
perhaps returning an empty array but with the indexes set to '' by default if no Customer exists here https://github.com/easydigitaldownloads/easy-digital-downloads/blob/master/includes/user-functions.php#L316 ?

@ashleyfae ashleyfae added this to the 2.10 milestone Oct 1, 2020
@ashleyfae
Copy link
Contributor

To reproduce:

  1. Create a new user. Do not make them a customer.
  2. Manually run edd_get_purchase_stats_by_user() with their user ID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants