impress-org / givewp

GiveWP - The #1 Donation Plugin for WordPress. Easily accept donations and fundraise using your WordPress website.
https://givewp.com/
GNU General Public License v3.0
346 stars 192 forks source link

Invalid Argument Supplied when no Donation Levels #2451

Closed cwsterling closed 6 years ago

cwsterling commented 7 years ago

Issue Overview

If you have a donation form with only custom amount turned on and no donation levels, you get an Invalid argument supplied for foreach()

Expected Behavior

Only custom donation level input shows

Current Behavior

Custom input shows, but also PHP errors show if errors are allowed to be shown.

Warning: Invalid argument supplied for foreach() in /srv/users/serverpilot/apps/fixingtheboro/public/wp-content/plugins/give/includes/forms/template.php on line 146
Warning: Invalid argument supplied for foreach() in /srv/users/serverpilot/apps/fixingtheboro/public/wp-content/plugins/give/includes/price-functions.php on line 96
Warning: Invalid argument supplied for foreach() in /srv/users/serverpilot/apps/fixingtheboro/public/wp-content/plugins/give/includes/forms/template.php on line 501 

Possible Solution

Check that the array isn't null before passing into the foreach

Steps to Reproduce (for bugs)

https://fixingtheboro.com/donations/adoption/

  1. Create a new donation form
  2. Delete all the donation levels
  3. Allow for custom levels
  4. View on donation form page.

Related Issues and/or PRs

Todos

WordPress Environment

``` ### WordPress Environment ### Home URL: https://fixingtheboro.com Site URL: https://fixingtheboro.com WP Version: 4.9.1 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: – WP Cron: ✔ Language: en_US Permalink Structure: /%year%/%monthnum%/%day%/%postname%/ Show on Front: page Page on Front: Welcome (#2) Page for Posts: Unset Table Prefix Length: 14 Table Prefix Status: Acceptable Admin AJAX: Inaccessible Registered Post Statuses: publish, future, draft, pending, private, trash, auto-draft, inherit, wc-pending, wc-processing, wc-on-hold, wc-completed, wc-cancelled, wc-refunded, wc-failed, refunded, failed, revoked, cancelled, abandoned, processing, preapproval ### Server Environment ### Hosting Provider: DBH: localhost, SRV: fixingtheboro.com TLS Connection: Connection uses TLS 1.2 TLS Connection: Probably Okay Server Info: Apache/2.4.28 (Unix) OpenSSL/1.0.2g PHP Version: 7.1.11 PHP Post Max Size: 1 GB PHP Time Limit: 30 PHP Max Input Vars: 5000 PHP Max Upload Size: 512 MB cURL Version: 7.47.0, OpenSSL/1.0.2g SUHOSIN Installed: – MySQL Version: 5.7.20 Default Timezone is UTC: ✔ fsockopen/cURL: ✔ SoapClient: ✔ DOMDocument: ✔ gzip: ✔ GD Graphics Library: ✔ Multibyte String: ✔ Remote Post: ✔ Remote Get: ✔ ### Give Configuration ### Give Version: 1.8.16 Upgraded From: 1.8.13 Test Mode: Disabled Currency Code: USD Currency Position: After Decimal Separator: . Thousands Separator: , Success Page: https://fixingtheboro.com/donation-confirmation/ Failure Page: https://fixingtheboro.com/donation-failed/ Donation History Page: https://fixingtheboro.com/donation-history/ Give Forms Slug: /donations/ Enabled Payment Gateways: Offline Donation, PayPal Standard Default Payment Gateway: PayPal Standard PayPal IPN Verification: Enabled PayPal IPN Notifications: IPN received for #861 ( 6AE524058W969342N ) on 12/03/2017 at 19:01. Status VERIFIED Admin Email Notifications: Enabled Donor Email Access: Disabled ### Session Configuration ### Give Use Sessions: Enabled Session: Disabled ### Active Give Add-ons ### ### Other Active Plugins ### Advanced Order Export For WooCommerce: by AlgolPlus – 1.5.0 Easy HTTPS (SSL) Redirection: by Tips and Tricks HQ – 1.7 Google Analytics for WordPress by MonsterInsights: by MonsterInsights – 6.2.6 Ninja Forms: by The WP Ninjas – 3.2.4 Redirection: by John Godley – 2.10 Seamless Donations: by David Gewirtz – 4.0.20 SparkPost: by SparkPost – 3.0.1 URL Coupons for WooCommerce: by Rymera Web Co – 1.0.2 WooCommerce: by Automattic – 3.2.4 WooCommerce PayPal Powered by Braintree Gateway: by WooCommerce – 2.0.4 Wordfence Security: by Wordfence – 6.3.21 WP Mail Logging: by Christian Zöller – 1.8.3 YITH Pre-Order for WooCommerce: by YITHEMES – 1.1.3 ### Inactive Plugins ### Akismet Anti-Spam: by Automattic – 4.0.1 Google Captcha (reCAPTCHA) by BestWebSoft: by BestWebSoft – 1.33 ### Theme ### Name: Sparkling Version: 2.3.5 Author URL: http://colorlib.com/ Child Theme: No – If you're modifying Give on a parent theme you didn't build personally, then we recommend using a child theme. See: How to Create a Child Theme ```
DevinWalker commented 6 years ago

@cwsterling thanks for submitting the issue. I'm curious, why are you using the "Multi-level" donation rather than "Set donation"?