-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
404 error when using permalinks #116
Comments
…cument-revisions#82 the 404 obtained when using a permalink. When using a permalink, the process serve_file uses get_attached_file which uses a cached version of the upload directory without direct reference to the specific post. This gives the standard directory. If the user has defined a different directory then this is not used - and the 404 results. A solution would be to invoke a filter on get_attached_file - but as it will essentially have to do the str_replace on the file name, the code is put directly
…cument-revisions#82 the 404 obtained when using a permalink. When using a permalink, the process serve_file uses get_attached_file which uses a cached version of the upload directory without direct reference to the specific post. This gives the standard directory. If the user has defined a different directory then this is not used - and the 404 results. A solution would be to invoke a filter on get_attached_file - but as it will essentially have to do the str_replace on the file name, the code is put directly
@kellybeth7 For some other change I was making I had set debug on for the document_upload_dir_filter(), I saw that this was not being invoked. Clearly it ought to have been. So I went through the code further. get_attached_file returns the file name of the attachment using the standard upload directory. I have put a commit (#119) that gets the attached name and then modifies it if the document directory is not the standard one. Would you be able to copy out the code and give it a test please? |
It looks like that resolves it. My documents now load fine when using a custom directory location. |
I believe #119 may fix this. Please try version 3.1.2. |
Per https://wordpress.org/support/topic/permalinks-not-working-after-upgrade-from-2-2-0-to-3-1-1/#post-10020203, I believe this is fixed, but please comment/reopen if that is not the case. |
This does not appear to be fixed as I have updated to the latest version 3.2.2 just now and still links do not work. I have tried changing the media settings but nothing seems to work. Here is a link to document I have added and shows as added in admin but links do not work for permalinks. http://spg-i.com/documents/2019/04/test.pdf I noticed the files being uploaded are actually being renamed to long strings like so 14820c7746e7f4fb9416d179285ebcff In the admin in media I do not see any of the documents showing. If i delete the plugin the documents with the long string name then show. Any help would be greatly appreciated. :) |
I am experiencing 404 errors when using permalinks for documents that are in a directory other than the default. I want to store files outside of public_html/htdocs, so I created a folder there. I updated the setting Document Upload Directory setting under Settings->Media. Documents appear to upload to my custom directory with no issues. However, I am unable to access any of the files with the generated permalink.
I did some digging around in the plugin code, and I believe I have found where things are going wrong, but I am not sure how it should be fixed. In document_upload_dir_filter(), the first thing it does is a check using verify_post_type(). I assume that this should pass for a document, but it seems to fail instead. Since it fails, it does not update the paths in $dir. That causes the file to be loaded from the default uploads folder instead of the custom location. Since the file isn't there, it causes a 404. If I comment out the verify check, my file loads perfectly. Commenting it out does break other things in my WP install, so I guess that's not really a solution.
I had seen that the post or post id was passed into the verify function in other cases, so I spent some time trying to figure out if there was anything available that I might be able to pass in to fix the check, but I wasn't able to find anything.
I am using WordPress 4.9.4 and WP Document Revisions 3.1.1.
The text was updated successfully, but these errors were encountered: