WordPress.org

Make WordPress Core

Opened 5 months ago

Closed 4 months ago

#46375 closed defect (bug) (duplicate)

WordPress discovery MIME type

Reported by: killua99 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Upload Keywords:
Focuses: Cc:

Description

Some plugins, like WooCommerce are having problems when trying to upload a CSV file.

Seems to be an issue in the PHP Library itself or not I'm 100 % clear yet. In my case on Pantheon server I've this issue with WordPress 5.1 and WooCommerce 3.5.5

Good description about it is in this comment https://wordpress.org/support/topic/wp-5-0-1-breaks-woocommerce-csv-import/page/2/#post-11234845 where @tgglv point out that the PHP Library finfo_open seems to act different. And perhaps the use of /usr/share/misc/magic should improve that finfo.

The function affected is https://github.com/WordPress/WordPress/blob/master/wp-includes/functions.php#L2558

Something like this library: https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types Could help to figure the mime.

This php component use it.
https://github.com/ralouphie/mimey

Trace issues:

https://core.trac.wordpress.org/ticket/45615
https://github.com/woocommerce/woocommerce/issues/22208

/cc @dougaitken

Change History (5)

This ticket was mentioned in Slack in #core by killua99. View the logs.


5 months ago

#2 @dougaitken
5 months ago

I have set up a Pantheon dev site to test this.

I installed the latest WooCommerce, and the site was launched with WP 5.1, WC 3.5.5

I went through the WooCommerce onboarding wizard and gave the basic details.

I then chose to import products via CSV. I saved this file locally as sample_products.csv and chose that - https://github.com/woocommerce/woocommerce/blob/master/sample-data/sample_products.csv

Image:
https://cld.wthms.co/3uERVh

Everything imported as expected. Site can be viewed here - http://dev-doug-wc-wp.pantheonsite.io/shop/

I'm unsure how to replicate this since it seems I'm using the same server environment and haven't got this issue.

I can only guess that there is indeed some server setups which have a different PHP library or something?

Version 0, edited 5 months ago by dougaitken (next)

#3 @tgglv
5 months ago

I use Bluehost shared host.

Software versions:

  • WordPress 5.1
  • WooCommerce 3.5.5
  • PHP 7.2.15
  • fileinfo 1.0.5

This ticket was mentioned in Slack in #core-media by killua99. View the logs.


4 months ago

#5 @desrosj
4 months ago

  • Component changed from General to Upload
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 5.1 deleted

Hello, all. Thanks for creating this ticket and sorry to hear you are experiencing issues.

This issue stems from a security patch that was applied in WordPress 5.0.1 that changed how mime types for files are processed to ensure the file actually matches the type the extension indicates it is. This was a backwards compatibility break and is detailed in this blog post.

After 5.0.1, there were many tickets created (#45655 and 45630, to name a few). The issue was solved for CSVs (and a few other common file types) in version 5.0.3 (see commit [44438] and issue #45615). This fix is included in all versions following 5.0.3, which includes 5.1. WooCommerce decided to not ship a fix for this and instead waited for 5.0.3 to be released.

#40175 is a second ticket that is being worked on that will fix the issue more completely.

As for the CSV not uploading in WooCommerce (or Core in general), I have been unable to reproduce the issue under the following scenarios (all with fresh installs of WordPress, and no plugins active unless listed):

  • WP 5.0.4, no plugins: uploading a CSV works in the media library.
  • WP 5.0.4, WooCommerce: uploading a CSV works in the media library and the WooCommerce product import feature.
  • WP 5.1.1, no plugins: uploading a CSV works in the media library.
  • WP 5.1.1, WooCommerce: uploading a CSV works in the media library and the WooCommerce product import feature.

I am going to close this as a duplicate of the ticket included in 5.0.3 because that should have fixed the issue. I don't doubt that you are still experiencing issues, but it does not seem to be a Core issue.

If you have an Apache mime type configuration on your server, you will need to follow up with your hosting company. If you are using the mimey library linked to in the description, you will need to open a ticket with them.

Some other possible causes:

  • A plugin that was activated while trying to fix is still active.
  • A configuration adjustment made trying to solve the issue is still present.
  • The upgrade process did not correctly replace all core files.
  • The CSV file being uploaded is not a proper CSV file.

If you are still encountering issues after checking these things, please open a new support issue on the WordPress.org support forums. When details are added on to resolved issues (like the one in the description) in the forum, support staff is unaware that the tickets need addressing.

Note: See TracTickets for help on using tickets.