awesomemotive / easy-digital-downloads

Sell digital downloads through WordPress
https://easydigitaldownloads.com
GNU General Public License v2.0
866 stars 473 forks source link

3.0 - PHP Fatal error during "Step 1: Upgrade Orders" #7620

Closed danieliser closed 4 years ago

danieliser commented 4 years ago

Bug Report

Expected behavior

Upgrades run smoothly.

Actual behavior

When running "Step 1: Upgrade Orders", and it gets to the 98%+ range it gets a 500 error during the ajax process, stopping it from finishing.

image

image

Steps to reproduce the behavior

1) Run step 1 upgrade.

Information (if a specific version is affected);

PHP Version: 7.3 EDD Version (or branch): release/3.0 WordPress Version: 5.3.2

Any other relevant information:

Stack Trace:

PHP Fatal error: Uncaught Error: Class 'EDD\\Admin\\Upgrades\\v3\\DateTime' not found in /wp-content/plugins/easy-digital-downloads/includes/admin/upgrades/v3/class-data-migrator.php:416

#0 /wp-content/plugins/easy-digital-downloads/includes/admin/upgrades/v3/class-orders.php(61): EDD\\Admin\\Upgrades\\v3\\Data_Migrator::orders(Object(stdClass))
#1 /wp-content/plugins/easy-digital-downloads/includes/admin/upgrades/v3/class-base.php(123): EDD\\Admin\\Upgrades\\v3\\Orders->get_data()
#2 /wp-content/plugins/easy-digital-downloads/includes/admin/reporting/export/export-functions.php(62): EDD\\Admin\\Upgrades\\v3\\Base->process_step()
#3 /wp-includes/class-wp-hook.php(288): edd_do_ajax_export('')
#4 /wp-includes/class-wp-hook.php(312): WP_Hook->apply_filters('', Array)
#5 /wp-includes/plugin.php(478): WP_Hook->do_action(Array)
#6 /wp-content/plugins/easy-digital-downloads/includes/admin/upgrades/v3/class-data-migrator.php on line 416

Referrer: /wp-admin/index.php?page=edd-upgrades&edd-upgrade=v30_migration

EDD Info

-- EDD Configuration

Version:                  3.0.0-beta-1.0012
Upgraded From:            2.8.11
Test Mode:                Disabled
AJAX:                     Enabled
Guest Checkout:           Disabled
Symlinks:                 Disabled
Download Method:          Direct
Currency Code:            USD
Currency Position:        before
Decimal Separator:        .
Thousands Separator:      ,
Upgrades Completed:       upgrade_customer_payments_association,upgrade_payment_taxes,sl_add_bundle_licenses,upgrade_user_api_keys,remove_refunded_sale_logs,fix_24_stripe_customers,upgrade_24_subscriptions,sl_deprecate_site_count_meta,recurring_27_subscription_meta,stripe_customer_id_migration,upgrade_mailchimp_api3,upgrade_mailchimp_api3_default_list,recurring_paypalproexpress_logs,eddmc_304_interests_fix,aa_v1_reorganize_customer_meta,migrate_licenses,migrate_license_parent_child,migrate_license_logs,remove_legacy_licenses,update_file_download_log_data,recurring_add_tax_columns_to_subs_table,fix_no_url_check_activation_counts,recurring_cancel_subs_if_times_met,aa_fix_utc_timezones,recurring_add_price_id_column,recurring_update_price_id_column
Download Link Expiration: 72 hour(s)

-- EDD Database Tables

customers:                      201810090001
customermeta:                   201807110001
customer_addresses:             201906250001
customer_email_addresses:       201808170001
adjustments:                    201906030001
adjustmentmeta:                 201806140002
notes:                          201807270003
notemeta:                       201805220001
orders:                         201901110001
ordermeta:                      201805220001
order_items:                    201906240001
order_itemmeta:                 201805220001
order_adjustments:              201807270003
order_adjustmentmeta:           201805220001
order_addresses:                201906280001
order_transactions:             201807270003
logs:                           201807270003
logmeta:                        201805220001
logs_api_requests:              201807270003
logs_api_requestmeta:           201907290001
logs_file_downloads:            201806280001
logs_file_downloadmeta:         201907290001

-- EDD Database Row Counts

customers:                      8666
customermeta:                   15859
customer_addresses:             9636
customer_email_addresses:       0
adjustments:                    0
adjustmentmeta:                 0
notes:                          0
notemeta:                       0
orders:                         15846
ordermeta:                      154301
order_items:                    16402
order_itemmeta:                 11733
order_adjustments:              330
order_adjustmentmeta:           766
order_addresses:                15302
order_transactions:             10340
logs:                           0
logmeta:                        0
logs_api_requests:              0
logs_api_requestmeta:           0
logs_file_downloads:            0
logs_file_downloadmeta:         0

-- EDD Page Configuration

Checkout:                 Valid
Checkout Page:            /checkout/
Success Page:             /checkout/purchase-confirmation/
Failure Page:             /checkout/transaction-failed/
Downloads Slug:           /extensions

-- EDD Gateway Configuration

Enabled Gateways:         PayPal Express, Stripe
Default Gateway:          Stripe

-- EDD Tax Configuration

Taxes:                    Disabled
Default Rate:             0%
Display On Checkout:      Displayed
Prices Include Tax:       No

-- Must-Use Plugins

EDD Software Licensing Endpoint: 1.0.1
Force Strong Passwords - WPE Edition: 1.6.4
ManageWP - Worker Loader: 
WP Engine Seamless Login Plugin: 1.5.3
WP Engine Security Auditor: 1.0.8
WP Engine System:         3.2.3

-- WordPress Active Plugins

* Beaver Custom Logic Rules: 1.0
* Custom Store Site Functionality: 1.0.0
* EDD - Clean unused & expired discounts: 1.0
* EDD - Custom Email Templating: 
* EDD - Disable PayPal for Multi-Item Checkout: 1.0
* Old Optin Tracking Server: 1.0.0
* PUM Site: Store Functionality: 1.0.0
* Smartlook - Disable for Admins: 100000000
ACF Content Analysis for Yoast SEO: 2.3.0
Advanced Custom Fields: Star Rating Field: 1.0.2
Advanced Custom Fields: Table Field: 1.3.9
Advanced Custom Fields PRO: 5.8.7
AffiliateWP:              2.4.4
AffiliateWP - Affiliate Area Shortcodes: 1.1.7
AffiliateWP - Affiliate Area Tabs: 1.2.8
AffiliateWP - Affiliate Dashboard Sharing: 1.1.6
AffiliateWP - Direct Link Tracking: 1.1.4
Ahoy:                     1.2.0
Ahoy - Easy Digital Downloads: 1.1.0
Ahoy - Exit Intent:       1.0.1
Ahoy - HelpScout:         1.0.0
Ahoy - Scroll Triggers:   1.0.1
Akismet Anti-Spam:        4.1.3
AMP:                      1.4.4
Beaver Builder Plugin (Pro Version): 2.3.2.2
Beaver Themer:            1.3.0.1
Cloudways WordPress Migrator: 3.4
Code Snippets:            2.14.0
Custom Post Type UI:      1.7.3
Disable Emails:           1.6.1
Easy Digital Downloads:   3.0.0-beta-1
Easy Digital Downloads - All Access: 1.1.4
Easy Digital Downloads - Amazon S3: 2.3.8
Easy Digital Downloads - Campaign Tracker: 1.0.0
Easy Digital Downloads - Discounts Pro: 1.4.8
Easy Digital Downloads - Git Download Updater: 1.1.1
Easy Digital Downloads - Hide Download: 1.2.8
Easy Digital Downloads - Invoices: 1.1.6
Easy Digital Downloads - Limit Cart Items Query Arg: 1.0
Easy Digital Downloads - MailChimp: 3.0.11
Easy Digital Downloads - Manual Purchases: 2.0.5
Easy Digital Downloads - PayPal Website Payments Pro and PayPal Express Gateway: 1.4.5
Easy Digital Downloads - PDF Invoices: 2.2.24
Easy Digital Downloads - Recommended Products: 1.2.12
Easy Digital Downloads - Recurring Payments: 2.9.8
Easy Digital Downloads - Software Licensing: 3.6.8
Easy Digital Downloads - Stripe Payment Gateway: 2.7.6
Easy Digital Downloads - Terms Per Product: 1.0.6
Easy Digital Downloads - Wallet: 1.1.4
Easy Digital Downloads - Zapier: 1.3.9
Easy Digital Downloads integration for HelpScout: 2.0
Easy Digital Downloads Putler Connector: 2.5.8.1
Easy Theme and Plugin Upgrades: 2.0.1
EDD gravity forms license check: 1.0.4
EDD Metrics:              1.0
Force Plugin Updates Check: 1.0.2
Glue for Yoast SEO & AMP: 0.6
Gravity Forms:            2.4.17
Gravity Forms - Help Scout Docs Search Field: 3.0.2
Gravity Forms Help Scout Add-On: 1.12
Gravity Forms MailChimp Add-On: 4.6
Health Check & Troubleshooting: 1.4.2
HurryTimer:               2.2.21
Iframe Resizer - Content Window Helper: 3.6.1
Imagify:                  1.9.9
instant.page:             3.0.0
Instant Articles for WP:  4.2.0
Jilt for Easy Digital Downloads: 1.5.1
Logo Carousel:            3.2.8
Logo Carousel Pro:        3.3.10
Mailster - Email Newsletter Plugin for WordPress: 2.2.3 (needs update - 2.4.8)
Mailster Google Analytics: 1.2
Mailster Mandrill:        1.1
ManageWP - Worker:        4.9.3
MediaRon Beaver Builder Modules: 1.3.1
MonsterInsights - AMP Addon: 1.4.5
MonsterInsights - Dimensions Addon: 1.3.0
MonsterInsights - eCommerce Addon: 7.3.5
MonsterInsights - EU Compliance: 1.1.0
MonsterInsights - Facebook Instant Articles Addon: 1.1.1
MonsterInsights - Forms Tracking Addon: 1.5.0
MonsterInsights - Google Optimize Addon: 1.3.0
MonsterInsights - Page Insights Addon: 1.3.0
MonsterInsights - Performance Addon: 1.4.0
MonsterInsights Pro:      7.10.4
Ninja Forms:              3.4.23 (needs update - 3.4.24)
Ninja Forms - Addon Manager: 3.0.13
Ninja Forms - Help Scout: 3.1.2
Ninja Forms - Layout & Styles: 3.0.28
Ninja Forms - Mail Chimp: 3.1.11
NotificationX:            1.6.0
NotificationX Pro:        1.4.8
oEmbed Gist:              4.9.1
Pixel Caffeine:           2.1.1
Pluginception:            1.3
Popup Maker:              1.9.1
Popup Maker - Advanced Targeting Conditions: 1.4.6
Popup Maker - Advanced Theme Builder: 1.1.6
Popup Maker - Exit Intent Popups: 1.4.0
Popup Maker - Forced Interaction: 1.1.0-alpha.1
Popup Maker - Remote Content: 1.1.4
Popup Maker - Scroll Triggered Popups: 1.3.2
Post Duplicator:          2.20
PowerPack for Beaver Builder: 2.7.11.1
Pretty Links:             3.1.0
Simple Custom CSS and JS PRO: 4.18
SmartLook Visitor Recording: 2.1.1
Social Warfare:           3.6.1
Social Warfare - Pro:     3.6.1
Surbma | Yoast SEO Sitemap to robots.txt: 2.0
Temporary Login Without Password: 1.6.0
Ultimate Addons for Beaver Builder: 1.25.2
User Menus:               1.2.2
User Switching:           1.5.4
Wider Gravity Forms Stop Entries: 1.0
WP Fusion:                3.29.4
WPMU DEV Dashboard:       4.7.5
WP Overnight Sidekick:    2.2.0
WP Retina 2x Pro:         5.6.0
WP Rocket:                3.4.4
Yoast SEO Premium:        13.1
danieliser commented 4 years ago

Seems the solution may be simple, checked those lines on local and they are calling root classes inside a namespace without the \

        $date_created_gmt  = new DateTime( $data->post_date );
        $modified_time     = new DateTime( $data->post_modified );
        $modified_time_gmt = new DateTime( $data->post_modified_gmt );

Should be

        $date_created_gmt  = new \DateTime( $data->post_date );
        $modified_time     = new \DateTime( $data->post_modified );
        $modified_time_gmt = new \DateTime( $data->post_modified_gmt );

Testing this on our staging to see if that upgrade completes now. If it does I can get a PR submitted for this shortly.

danieliser commented 4 years ago

Seems there are also calls to new DateInterval that are missing the root slash.

Do you guys prefer \DateTime or rather just adding use \DateTime; near the top?

danieliser commented 4 years ago

These fixes worked to resolve those issues. The process is still running on our 5 year old store, but so far so good.

I need to know your preference of prefixing each usage or calling use at the top of the file.

pippinsplugins commented 4 years ago

Throughout the codebase, we use the use \DateTime logic only for EDD-specific classes, so I would opt for just \DateTime.