WordPress.org

Ready to get started?Download WordPress

Forums

WP Document Revisions
[resolved] 404 error and permalinks are set correctly (15 posts)

  1. Naturalrush
    Member
    Posted 2 years ago #

    I can upload documents and see them but get a 404 on trying to access them. I have the permalinks set according to what was listed in the FAQ. What other infomation do you need to troubleshoot?

    -Ray

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

  2. Ben Balter
    Member
    Plugin Author

    Posted 2 years ago #

    What version of WordPress? What version of the plugin? Does the file upload properly? Also, what type of 404 is it? Standard WordPress 404, Apache 404, or a grey screen white a white box that says "404 - file not found"?

  3. Naturalrush
    Member
    Posted 2 years ago #

    Ben, thanks for getting back to me so quick.

    WP is 3.2.1.

    The document uploaded fine and saw the file with the hashed filename added to the uploads folder.

    It was that weird 404 with the gray page.

    I've worked in depth with WP before but it's not that frequent. I think I followed all the instructions for setup and use. One thing I noticed about the doc URL was a trailing slash after the filename. Seemed a bit odd but maybe that's how it works.

    -Ray

  4. Naturalrush
    Member
    Posted 2 years ago #

    Ben or anyone else, I'm trying to get this plugin to work. After not getting anywhere I let it sit and here I go giving it another shot with the new 1.1 version. I'm getting the same thing, a 500 internal server error. In WP there is a 404 error (WP generated, not Apache) displayed. What I have noticed is there is a 301 redirect then the 500 error. Is the trailing slash supposed to be there? Below is are the line from the Apache log with a blank line put between them.

    192.168.146.1 - - [24/Oct/2011:21:52:46 -0400] "GET /parkway/documents/2011/10/another-doc.pdf HTTP/1.1" 301 - "http://rushr-lt/parkway/wp-admin/post.php?post=391&action=edit&message=1" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"
    
    192.168.146.1 - - [24/Oct/2011:21:52:46 -0400] "GET /parkway/documents/2011/10/another-doc.pdf/ HTTP/1.1" 500 1165 "http://rushr-lt/parkway/wp-admin/post.php?post=391&action=edit&message=1" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1"

    No PHP errors show up. Any suggestions are welcome.

  5. Ben Balter
    Member
    Plugin Author

    Posted 2 years ago #

    Again, sorry to hear you're still having trouble.

    I don't think the trailing slash is the culprit, as I believe it happens after the file is not found, but I'm not sure what's going on with the 500 error.

    Steps I'd take to troubleshoot, (1) track down that 500 error (most likely in your PHP error log), and (2) trap the file that WP is trying to access around line 582 of wp-document-revisions.php, and verify the path is correct.

    Otherwise, I assume it's a standard install? Did you move your upload directory?

  6. Naturalrush
    Member
    Posted 2 years ago #

    Ben, thanks for the pointer of where to check in wp-document-revisions.php.

    For the particular file I was testing with, I get the string as shown below with mixed slashes. Note that I am testing this on a WAMP setup. This is no good.

    C:\xampp\htdocs\parkway/wp-content\uploads/4d1dd0c48d811ee913f6370de0481c08.pdf

    I can fix this with str_replace, but then validate_file fails on line 584. Checking the documentation I could find on this (below), it automatically fails on Windows systems with a result of 2.
    http://phpdoc.wordpress.org/trunk/WordPress/_wp-includes---functions.php.html

    So, away goes validate_file on line 584, leaving only is_file to check things, and add a str_replace for consistent slashes before I hit that.

    It works.

    Thanks,
    -Ray

  7. Ben Balter
    Member
    Plugin Author

    Posted 2 years ago #

    Ahh. Glad we were able to get to the bottom of that. I think some of those slashes are my fault, and can work on cleaning them up a bit for the next release -- I'll take a closer look at how core handles validate_file. Either way, glad to hear it's working.

    Thanks,
    - Ben

  8. rodrigl2
    Member
    Posted 2 years ago #

    Hi Benjamin,

    I have installed your plug-in and I have the same issue ( 404 — File not found. ) ... I am using XAMP over windows and WordPress 3.2.1.

    I have reviewed the .httacces the xampp module ,rights, changed the permalinks several times to test the scenarios but I could not solve the issue.

    follows the link http://inside/sbf/?post_type=document&p=442
    (this is an intranet website ) and the files are being saved on directory correctly.

    Could you give some other directions to solve it?

    Really your plug-in has benefits for our workteam.

    thanks in advance,

  9. DKowalski
    Member
    Posted 2 years ago #

    Hi Benjamin,

    first of all, thanks for all the work you put into the plugin, its greatly appreciated!

    Since version 1.2 the revision summary bug is gone and the plugin now works great on my local MAMP-installation. On our Windows XAMPP-installation however, I get exactly the same error as Naturalrush.

    Any ideas what's causing this? Maybe differences in the handling of rewrite-rules?

    Greetings

  10. Ben Balter
    Member
    Plugin Author

    Posted 2 years ago #

    As Naturalrush correctly pointed out, looks like it's failing for two distinct reasons: 1) backslashes vs. forward slashes in the UL as a result of being a Windows system, and 2) WP's validate_file function which returns an error on Windows systems.

    I'll be sure to clean this up in the next minor release, most likely next week pending any other bugs.

    Interim fixes:

    1) Remove "validate_file( $file ) ||" from line 589 of wp-document-revisions.php. ( In hindsight, this security check is not necessary here and is safe to remove )

    2) Either flip the slashes on line 388 or apply a filter to the permalink to do the same, e.g.:

    add_filter( 'document_permalink', 'bb_flip_slashes' );
    
    function bb_flip_slashes( $url ) {
         return str_replace( '/', '\', $url );
    }

    I'll be sure that it appends the proper slashes moving forward.

    Sorry for the trouble, and thanks for the kinds words.

    - Ben

  11. Ben Balter
    Member
    Plugin Author

    Posted 2 years ago #

    Correction for the bb_flip_slashes() function above, this is lifted from class WP_Filesystem:

    $url = preg_replace('|^([a-z]{1}):|i', '', $url); //Strip out windows drive letter if it's there.
    return str_replace('\\', '/', $url); //Windows path sanitisation

    1) removes drive letter, 2) escapes the slash so PHP doesn't err out, 3) proper order of arguments on str_replace.

  12. DKowalski
    Member
    Posted 2 years ago #

    It works, thanks for your support!

  13. Ben Balter
    Member
    Plugin Author

    Posted 2 years ago #

    I updated the development version with a modified version of the fix outlined above.

    I believe its a file path issue, not a permalink issue. Validate file should now be removed, and the above filter is being run prior to WP retrieving the file (rather than before the permalink is displayed, as originally outlined above).

    Please give the new version a try (also available in trunk via SVN), and if it resolves the issue, will be in the next release.

  14. DKowalski
    Member
    Posted 2 years ago #

    I just tested your development version against the current WordPress release 3.2.1 with our Windows / XAMPP setup and on my local OS X / MAMP installation against the latest nightly build of WordPress 3.3. Both installations seem to run flawless.

    Greetings,

    Daniel

  15. silent0
    Member
    Posted 2 years ago #

    Was just testing the dev version of your plugin (1.2.1) on my Windows PC running WAMP and can also confirm that the patch is working.

    PS - thanks for building this awesome plugin!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic