I’m seeing the same problem. Here’s some info I’ve discovered while stepping thru both the 3.6.3 and 4.0.0 code in a debugger:
1. the problem seems to be in the new FileModel
class (just like the problem I reported in regression in 4.0.0 on windows. Same class, but different problem and in this case the problem is not Windows-specific)
2. the emrFile::__construct()
method in 3.6.3 uses wp_check_filetype_and_ext()
to get the mime type of the file (the “sourceFile” in this case); whereas, FileModel::getMime()
in 4.0.0 uses wp_get_image_mime()
, which only works for images.
It is because of #2 that version 4.0.0 only knows what the mime type of the sourceFile (i.e., the existing file that is being replaced) when it is an image file…and not when it’s a “document” (e.g., a PDF, XLSX, etc). I came across the problem when trying to replace an XLSX file.
Here’s the environment info: on Windows (where I stepped thru things in the debugger):
OS: Win11 Pro for Workstations (21H2, 22000.918)
PHP: 7.4.29
WP: 6.0.2
Apache: 2.4.53
MySQL: 5.7.38
And on Linux (where I first discovered the problem on a live site):
OS: CentOS 7
PHP 7.4.27
WP: 6.0.2
Apache: 2.4.6
MySQL: 5.7.36