Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

chmod() operation not permitted #19

Closed
ghost opened this issue Mar 30, 2017 · 2 comments
Closed

chmod() operation not permitted #19

ghost opened this issue Mar 30, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 30, 2017

We are using Pressbooks and the Pressbooks mPDF plugin on a hosting provider that does not allow the use of PHP's chmod() function and has a single dedicated place where plugins can write files to.

Our workaround for this was to comment out the chmod() line in pressbooks-mpdf.php and to symlink the ttfontdata, graph_cache, and tmp directories (in both vendor and symbionts/mpdf) to the directory our hosting provider allows write access to. All of this is to say that it works, but the solution we've implemented isn't ideal because it means we have to hack stuff in your code to make it work, and in the future when this plugin updates, we'll have to reimplement our changes.

My question is, why do the folders listed above need to be writable? What are they used for? Is there a way this plugin can work its magic without requiring write access to any files?

@bdolor
Copy link
Contributor

bdolor commented Apr 7, 2017

Hi @monkecheese — thanks for being patient for a response. The quickest explanation I have is that the reason the folders need to be writable is because that's what the documentation states is necessary.

reference:
https://mpdf.github.io/installation-setup/installation-v6-x.html

explanation:

mPDF is configured to use [your_path_to_mpdf]/tmp/ as a folder to write temporary files (mainly for images), and [your_path_to_mpdf]/ttfontdata/ as a folder to cache font metrics data. Write permissions should ideally be set on both these folders to allow read/write access for the script.

On the following page it describes two constants _MPDF_TEMP_PATH and _MPDF_TTFONTDATAPATH that can be set to change the location of the temporary files.

https://mpdf.github.io/installation-setup/folders-for-temporary-files.html

It's not clear to me if setting those constants would be a sufficient alternative to the work around that you've already employed or not. If you end up testing it, would you be able to report back? If there's anything that can be modified, let me know.

@ghost
Copy link
Author

ghost commented Apr 11, 2017

This is great, thanks @bdolor. When I have a moment to try a few things out, I'll let you know what I find.

Without having taken a dive into the code, my initial thought is that it may be possible to allow users of the plugin to set their own write path for ttfontdata, tmp, and graph_cache by setting those constants you mentioned with a filter hook.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant