WordPress.org

Ready to get started?Download WordPress

Forums

WP Document Revisions
Potential Fix - Delivering Corrupt docx (4 posts)

  1. WorldWideWebb
    Member
    Posted 1 year ago #

    Love the plugin, but we've been running into an issue lately in which viewing any docx (haven't fully tested this with xlsx and pptx, but excel files have so far exhibited the same behavior) comes back as corrupted. We try to either open or save the file out and open it with Word, and we either see gibberish or the file appears to be completely corrupted. I've made sure that the mime type being delivered by the web server (apache) is correct, and I've even tried bumping that back down to the old mime type for regular doc files, and none of that worked. After a lot of googling, I've seen other users with this issue (a couple said that they had conflicting plugins and disabling them corrected the issue - no such luck for me).

    I had also isolated a few other possibilities, such as a corrupt file to begin with, or an issue on upload (I pulled the uploaded & renamed file directly off of the server with FTP and hit the fully-qualified path to the file itself - both worked). Definitely something to do with when the file was being returned by the plugin.

    What finally worked for me (not sure if this is worth including in the plugin in a future fix) was to clean the output buffering and run flush() right before the file is delivered (immediately before "read_file( $file)" in the "serve_file" function. Added the following 2 lines:

    ob_clean();
    flush();

    Hope this helps someone.

    http://wordpress.org/plugins/wp-document-revisions/

  2. zanetaylor
    Member
    Posted 2 months ago #

    Thanks for this! It saved my bacon when Firefox and Internet Explorer were having trouble previewing my PDFs.

  3. DancingFighterG
    Member
    Posted 1 month ago #

    What file do I make this update too?

  4. WorldWideWebb
    Member
    Posted 1 month ago #

    It's the main plugin file: wp-document-revisions/wp-document-revisions.php

    Do a Ctrl-F for "serve_file", then scroll to the closing curly brace of that method. Add the lines directly before the "read_file( $file);" line.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic