Skip to content

Fatal Error when setting donation date to future #6698

Open
@flack

Description

@flack

User Story

As an admin, I want to set offline donations to Completed in the backend. If I mis-click in the date selector for some reason, I get a Fatal Error and an email is sent to the site administrator

Details

When you set the date of a donation to the future (most likely by accident), the follwing Fatal Error occurs:

 Fatal error: Uncaught UnexpectedValueException: Value 'future' is not part of the enum Give\Donations\ValueObjects\DonationStatus in wp-content/plugins/give/vendor/myclabs/php-enum/src/Enum.php on line 50

Expected Behavior

  • If you set an invalid (future) date, there should be a validation that prevents that.
  • also, the datepicker should just disable future dates so that the user is less likely to make that mistake
  • At the very least, no PHP-level error should be thrown.

Steps to Reproduce

  1. Go to the list of donations in the backend, click on one
  2. Set donation date to tomorrow
  3. Click "Save"
  4. View error

Additional Context

The easiest fix would probably be to add

const FUTURE = 'future';

to the constants here:

const PENDING = 'pending';
const PROCESSING = 'processing';
const COMPLETE = 'publish';
const REFUNDED = 'refunded';
const FAILED = 'failed';
const CANCELLED = 'cancelled';
const ABANDONED = 'abandoned';
const PREAPPROVAL = 'preapproval';
const REVOKED = 'revoked';

It does fix the Fatal Error, but I didn't test if it has any side effects

System Information

Details

Acceptance Criteria

  • Something happens when an action is taken.
  • Something does not happen when an action is taken.
  • Fixing behavior in Component A does not affect existing behavior in Component B.

Metadata

Metadata

Assignees

No one assigned

    Labels

    keep-fresh"Keep Fresh" issues should not be marked as stale.type: bugExisting functionality is broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions