Version 4 – Cannot replace pdf
-
Hi there, even though version 3.6.3 works perfectly, after updating to version 4 and trying to replace a pdf, I get an error telling that this file has a different file type and this could probably make some problems. After rolling back to 3.6.3 same file is replaced with no poblems
-
Hi satnapar,
Could you please send us the old file and the new one? In addition, is the issue happening with all files, all PDFs or only this PDF?
Finally, can you please send us a screenshot of the actual error? Please take the screenshot from the whole browser window, not only the error.
Thank you!
I am sending you some files that I just tested and the screenshot here https://we.tl/t-U5ZjSY5ZOm . Version 4 works as expected when replacing image-old.jpg with image-new.jpg. When trying with two different pdfs (pdf-test1-old.pdf replaced with pdf-test1.pdf, pdf-test2-old.pdf replaced with pdf-test2.pdf) I am getting the error that you can see on the screenshot
Thank you for your timeThanks, @satnapar!
I was able to reproduce the issue, so I’ll forward it to our developers so we can take care of it.
In the meantime, feel free to ignore the message. It’s just a warning, not an error, so nothing will happen.
Best,
I’m having the same issue. When replacing a PDF document, I get an error that the file format doesn’t match the file being replaced (even though they do, PDF). It does replace the document in the end, but error is always there.
Having the same issue on a client’s site, but the attachment is not being replaced at all.
Hello to all and thanks for reporting this!
After some testing, we narrowed down this issue to the Edge browser because according to our tests in Chrome, Safari, and Firefox everything works as expected, with no warnings about this, using the test files sent by @satnapar (thanks!). Most likely Edge isn’t properly detecting the newly uploaded file’s mime type, hence the message. And just to clarify: that message is a warning, not an error and the replacement is done correctly, despite the warning.
@webmarketingatters can you please give us more details about the file you want to replace and the new file? Are they both PDF files? What happens exactly when you try to replace it, do you get another message besides the one stated at the beginning of this thread? I just want to ensure you’re not having a different situation than the rest of the reporters.
Thank you!
@petredobrescu , just to notice that I am using Firefox on a mac and I am getting the warning
hm, that’s really interesting @satnapar, can you please tell me which webserver is your site using? Apache/NGINX/Litespeed/other?
Nginx
Hello,
I’m reporting same issue, using fully updated plugin version.
System info:
nginx/1.19.10
PHP 7.4.23
WordPress 5.9.4
Windows 10, Chrome Version 105.0.5195.127 (Official Build) (64-bit)I was able to replace the same files on another site running older version of enable media replace.
I can’t replace PDF at all.
Some more console info:
Checking delayed init emr_admin.js?ver=4.0.0:301 check upload status true emr_admin.js?ver=4.0.0:301 file size:513673 emr_admin.js?ver=4.0.0:301 Not image, media document emr_admin.js?ver=4.0.0:301 application/pdf notThe UI error: “The replacement file does not have the same file type. This can lead to unexpected issues ( – application/pdf )”
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
FileModelclass (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 useswp_check_filetype_and_ext()to get the mime type of the file (the “sourceFile” in this case); whereas,FileModel::getMime()in 4.0.0 useswp_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.38And 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.36Nice debugging @pbiron ! Which debugger and IDE did you use? I’m using Tracy debugger which didn’t show any error but it also doesn’t have step through debugging.
@petredobrescu the functionality does work even with the warning message.
I’m having the same problem trying to replace a zip file. I’m running the latest versions of WordPress and the plugin on Chrome on Windows 10.
I get these error messages, but am able to replace the file successfully:
The replacement file does not have the same file type. This can lead to unexpected issues ( – application/x-zip-compressed )
The replacement file type does not seem to be allowed by WordPress. This can lead to unexpected issuesSame issue here when replacing a PDF. Looks like @pbiron located the cause, hoping developer will push a fix soon.
Try it anyway with the PDF.
I get the error, but it still works. It replaces the PDF with no issues.
The topic ‘Version 4 – Cannot replace pdf’ is closed to new replies.