Closed e3betht closed 8 years ago
I don't understand how this works. How can you check the writability of a web URL?
You can check using the is_writable() function in PHP: http://php.net/manual/en/function.is-writable.php
We can also just check if the directory is writable, which would allow for line 213 to be moved after the is_writable() and prevent it from having to be duplicated. I can make that update in my PR if you'd like.
On 5/3/16 2:31 PM, Antti Kuosmanen wrote:
I don't understand how this work. How can you check the writability of a web URL?
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/anttiviljami/wp-pdf-templates/pull/18#issuecomment-216640106
Beth Tucker Long Treeline Design, LLC 807 Arbor Vitae Place Verona, WI 53593 608-770-6677 http://www.TreelineDesign.com
I'm sorry, but I think you're confused by what is_writable() does. It checks the writability of a file path in the filesystem, not a URL. Passing a URL value as a parameter to is_writable will always return false due to URLs starting with http:// or https:// not being valid filesystem paths.
I agree that just checking empty() is not enough, but this pull request will not work.
Closing this pull request.
Let me know if you can come up with a better way to check if localhost is configured correctly! :)
As of PHP 5.0, is_writable() supports file://, so we could use that instead of http:// to check writability of the dir.
Beth Tucker Long Treeline Design, LLC 807 Arbor Vitae Place Verona, WI 53593 608-770-6677 http://www.TreelineDesign.com
On May 3, 2016, at 14:38, Antti Kuosmanen notifications@github.com wrote:
I'm sorry, but I think you're confused by what is_writable() does. It checks the writability of a file path in the filesystem, not a URL. Passing a URL value as a parameter to is_writable will always return false due to URLs starting with http:// or https:// not being valid filesystem paths.
I agree that just checking empty() is not enough, but this pull request will not work.
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub
but then that would not help with our localhost problem :)
Really, what we should be checking is whether localhost points to the local Wordpress installation. That can't be done via the file:// URLs.
How about testing: if (file_put_contents($link, 'test') === false) {
This would tell us if the file is writable. Beth
On 5/3/16 3:19 PM, Antti Kuosmanen wrote:
Really, what we should be checking is whether localhost points to the local Wordpress installation. That can't be done via the file:// URLs.
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/anttiviljami/wp-pdf-templates/pull/18#issuecomment-216652593
Beth Tucker Long Treeline Design, LLC 807 Arbor Vitae Place Verona, WI 53593 608-770-6677 http://www.TreelineDesign.com
again. we can't file_put_contents to a http url. same issue as with is_writable.
From the PHP.net documentation for file_put_contents():
A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.
I checked, and allow_url_fopen has defaulted to 1 since PHP 4.0.4.
So, it's not a guarantee, but it's something.
On 5/3/16 3:31 PM, Antti Kuosmanen wrote:
again. we can't file_put_contents to a http url. same issue as with is_writable.
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/anttiviljami/wp-pdf-templates/pull/18#issuecomment-216655548
Beth Tucker Long Treeline Design, LLC 807 Arbor Vitae Place Verona, WI 53593 608-770-6677 http://www.TreelineDesign.com
This fixes Issue 17 (https://github.com/anttiviljami/wp-pdf-templates/issues/17) where $html is not empty, but localhost is not writable, which leads to blank PDFs. This is most likely to happen on shared hosting environments where localhost is not configured correctly.