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

fix: prevent error when importing JSON settings file #3907

Closed
2 of 3 tasks
samsmith89 opened this issue Dec 18, 2018 · 6 comments
Closed
2 of 3 tasks

fix: prevent error when importing JSON settings file #3907

samsmith89 opened this issue Dec 18, 2018 · 6 comments
Assignees

Comments

@samsmith89
Copy link

samsmith89 commented Dec 18, 2018

Bug Report

User Story

As a site admin, I want to import the JSON settings file from another installation so that I can quickly get Give set up in another site.

Current Behavior

When importing the JSON file from another site, I receive an error stating that the file is invalid.

Expected Behavior

I expect to import the file without receiving an error message.

Bug Type

  • I am not sure whether this functionality ever worked as expected.

Steps to Reproduce

  1. Export a JSON file from another Give installation
  2. In an empty site attempt to import the JSON settings file
  3. See that an error is thrown stating the file is invalid, and the import doesn't take place

Visuals

Possible Solution

screen shot 2018-12-18 at 10 00 39 am

Related

https://secure.helpscout.net/conversation/734568449/31321

Acceptance Criteria

  • I can import a settings JSON file without receiving an error
  • The import goes through without issue

Environment

Operating System
  • Platform: Mac OS X
Browser
  • Name: Chrome
WordPress System Info ### WordPress Environment ###

Home URL: http://destroy.local
Site URL: http://destroy.local
WP Version: 4.9.9
WP Multisite: –
WP Memory Limit: 256 MB
WP Debug Mode: –
WP Cron: ✔
Language: en
Permalink Structure: /%postname%/
Show on Front: page
Page on Front: Home – Movement For A Peoples Party (#9)
Page for Posts: Blog (#84)
Table Prefix Length: wp_
Table Prefix Length: 3
Table Prefix Status: Acceptable
Admin AJAX: Accessible
Registered Post Statuses: publish, future, draft, pending, private, trash, auto-draft, inherit, request-pending, request-confirmed, request-failed, request-completed, refunded, failed, revoked, cancelled, abandoned, processing, preapproval

Server Environment

Hosting Provider: DBH: localhost, SRV: destroy.local
TLS Connection: Connection uses TLS 1.2
TLS Connection: Probably Okay
Server Info: Apache/2.4.10 (Debian)
PHP Version: 7.0.3
PHP Post Max Size: 1,000 MB
PHP Time Limit: 900
PHP Max Input Vars: 3000
PHP Max Upload Size: 1,000 MB
cURL Version: ❌ 7.38.0, OpenSSL/1.0.1t - We recommend a minimum cURL version of 7.40.
SUHOSIN Installed: –
MySQL Version: 5.6.34
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
gzip: ✔
GD Graphics Library: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔

Give Configuration

Give Version: 2.3.1
Give Cache: Enabled
Database Updates: All DB Updates Completed.
Give Cache: Enabled
Give Cache: ✔New Donation✔Donation Receipt❌New Offline Donation❌Offline Donation Instructions✔New User Registration✔User Registration Information✔Donor Note✔Email access
Upgraded From: 2.3.0
Test Mode: Disabled
Currency Code: USD
Currency Position: Before
Decimal Separator: .
Thousands Separator: ,
Success Page: http://destroy.local/donation-confirmation/
Failure Page: http://destroy.local/donation-failed/
Donation History Page: http://destroy.local/donation-history/
Give Forms Slug: /donations/
Enabled Payment Gateways: PayPal Standard
Default Payment Gateway: PayPal Standard
PayPal IPN Verification: Enabled
PayPal IPN Notifications: IPN received for #8597 ( N/A ) on 11/21/2018 at 11:25. Status VERIFIED
Donor Email Access: Enabled

Active Give Add-ons

Give - Form Field Manager: ❌ Unlicensed – by GiveWP – 1.4.1

Other Active Plugins

Inactive Plugins

Theme

Name: bb-theme-child
Version:
Author URL:
Child Theme: Yes
Parent Theme Name: bb-theme-child
Parent Theme Version:
Parent Theme Author URL:

@kevinwhoffman kevinwhoffman changed the title fix: fix error stating that file is invalid when importing JSON settings file fix: prevent error when importing JSON settings file Dec 20, 2018
@kevinwhoffman
Copy link
Contributor

We tested a JSON settings import in WP 4.9.8 and it works. We confirmed the error is caused by the MIME type bug introduced in WP core 4.9.9/5.0.1. The core team is working on this issue and is planned for core 5.0.3. There is a gist available in this ticket but we need to confirm if it solves this JSON issue and possibly the related CSV issue:

https://core.trac.wordpress.org/ticket/45615#comment:13

@samsmith89
Copy link
Author

Sounds good. I'm updating the customer

@kevinwhoffman
Copy link
Contributor

Closing as WordPress core issue to be fixed in 5.0.3 with existing workaround.

@DevinWalker DevinWalker self-assigned this Jan 18, 2019
@DevinWalker DevinWalker reopened this Jan 18, 2019
@DevinWalker
Copy link
Member

DevinWalker commented Jan 18, 2019

Reopening as WP appears to not have resolve the issue for the JSON file type. We've had multiple reports of this including here: https://wordpress.org/support/topic/import-json-fails/

@kevinwhoffman
Copy link
Contributor

Here's a relevant Trac comment mentioning the upload_mimes filter as a potential fix.

I recommend we also follow the example in this test where the filter is added and then immediately removed after Give is done with it so that it does not enable JSON uploads universally throughout the site, but instead only where needed for importing settings.

/**
* @ticket 45615
* @dataProvider _wp_check_filetype_and_ext_unsupported
*/
function test_wp_check_filetype_and_ext_unsupported_filtered( $file, $filename, $expected ) {
     
    // With a filter these should succeed
    $ext = $expected['ext'];
    $mime_type = $expected['type'];
    $filter = function( $mimes ) use ( $ext, $mime_type ) {
        $mimes[ $ext ] = $mime_type;
        return $mimes;
    };
     
    add_filter( 'upload_mimes', $filter );
     
    $this->assertEquals( $expected, wp_check_filetype_and_ext( $file, $filename ) );
     
    remove_filter( 'upload_mimes', $filter );
}

@mathetos
Copy link
Member

I get nervous about removing the filter in the same function. If their JSON file is large will it timeout or the filter get removed before it's uploaded properly.

I think it's safer to just enable the filter on the Give admin screens.

DevinWalker added a commit that referenced this issue Jan 29, 2019
* release/2.4.1: (35 commits)
  refactor: remove old donation form exporter code
  chore: removed unnecessary code causing PHP warning and function cleanup
  fix: resolved make user actual logged out when click log out link
  chore: add method description
  fix: allow json uploads for settings import screen only on WP 5.0+ #3907
  fix: resolved php notice when donor address update
  chore: comment out PHPUnit testing code #3794
  chore: update plugin version to 2.4.1
  chore: add PHP 7.2 + 7.3 to travis tests
  fix: resolved log count is not correct when search for API log related to specific WP User
  fix: improve logic for cc field server side validations
  fix: company_name and name tag description changed as per requested
  fix: prevent error when exporting CSV between two dates
  fix: email tag description changed as per suggestion
  fix: allowed admin to update blank value for address input
  fix: improve conditional logic to work for stripe checkout as well
  fix: snippet added for make compatible X theme and Cornerstone plugin
  fix: add support for empty validation check to cc fields
  fix: php ruleset added for check give text domain
  chore: run npm update and test tasks to ensure compatibility
  ...
DevinWalker added a commit that referenced this issue Jan 29, 2019
* release/2.4.1: (39 commits)
  refactor: remove old donation form exporter code
  chore: removed unnecessary code causing PHP warning and function cleanup
  fix: resolved make user actual logged out when click log out link
  chore: add method description
  fix: allow json uploads for settings import screen only on WP 5.0+ #3907
  fix: resolved php notice when donor address update
  chore: comment out PHPUnit testing code #3794
  chore: update plugin version to 2.4.1
  chore: add PHP 7.2 + 7.3 to travis tests
  fix: resolved log count is not correct when search for API log related to specific WP User
  fix: improve logic for cc field server side validations
  fix: company_name and name tag description changed as per requested
  fix: prevent error when exporting CSV between two dates
  fix: email tag description changed as per suggestion
  fix: allowed admin to update blank value for address input
  fix: improve conditional logic to work for stripe checkout as well
  fix: snippet added for make compatible X theme and Cornerstone plugin
  fix: add support for empty validation check to cc fields
  fix: php ruleset added for check give text domain
  chore: run npm update and test tasks to ensure compatibility
  ...
DevinWalker added a commit that referenced this issue Feb 1, 2019
* release/2.4.1: (25 commits)
  fix: covert microtime to string
  chore: fix typo
  fix: param typo
  Revert "fix: ensure donor mailing addresses match when exporting to csv"
  fix: resolved donor export not correct when export donor.
  refactor: remove old donation form exporter code
  chore: removed unnecessary code causing PHP warning and function cleanup
  fix: resolved make user actual logged out when click log out link
  chore: add method description
  fix: allow json uploads for settings import screen only on WP 5.0+ #3907
  fix: resolved php notice when donor address update
  chore: comment out PHPUnit testing code #3794
  chore: update plugin version to 2.4.1
  chore: add PHP 7.2 + 7.3 to travis tests
  fix: resolved log count is not correct when search for API log related to specific WP User
  fix: improve logic for cc field server side validations
  fix: company_name and name tag description changed as per requested
  fix: prevent error when exporting CSV between two dates
  fix: email tag description changed as per suggestion
  fix: allowed admin to update blank value for address input
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants