[wp-trac] [WordPress Trac] #50913: PHP 8.0: various compatibility fixes

WordPress Trac noreply at wordpress.org
Sat Sep 26 01:07:21 UTC 2020

#50913: PHP 8.0: various compatibility fixes
 Reporter:  jrf                            |       Owner:  SergeyBiryukov
     Type:  task (blessed)                 |      Status:  reviewing
 Priority:  normal                         |   Milestone:  5.6
Component:  General                        |     Version:
 Severity:  normal                         |  Resolution:
 Keywords:  php8 has-patch needs-dev-note  |     Focuses:  coding-standards

Comment (by SergeyBiryukov):

 Looking at this failure:
 1) Tests_Functions::test_wp_check_filetype_and_ext with data set #13
 ('/var/www/tests/phpunit/includ...st.csv', 'test.csv', array('csv',
 'text/csv', false))
 Failed asserting that two arrays are identical.
 --- Expected
 +++ Actual
 @@ @@
  Array &0 (
 -    'ext' => 'csv'
 -    'type' => 'text/csv'
 +    'ext' => false
 +    'type' => false
      'proper_filename' => false

 It's caused by a change in PHP 8: previously the Fileinfo extension
 returned the `text/plain` MIME type for CSV files, and now it returns
 `application/csv`. `wp_check_filetype_and_ext()` does not take that new
 value into account.

 Relevant commits and issues upstream:
 * [https://github.com/php/php-
 a1fc08de77cf8ef1156afba154efc9a6 fileinfo: Upgrade to libmagic 5.39]
 PR/174: petre: The new CSV file identification is returning
 * [https://bugs.astron.com/view.php?id=174 0000174: CSV files identified
 as "application/csv" instead of registered "text/csv"]

 Per the comments in the issue 174 above, the incorrect type is now fixed
 and `text/csv` should be returned instead. However, it's not quite clear
 when that fix makes it into the PHP project.

 Since it's a safe change that should not affect anything else, I think
 `wp_check_filetype_and_ext()` should be updated to also check for
 `application/csv`, same as it currently does for `application/rtf`.

 This can be reverted later if the correct `text/csv` type makes it into
 the PHP 8 final release.

Ticket URL: <https://core.trac.wordpress.org/ticket/50913#comment:49>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list