chnm / anthologize

Anthologize is a free, open-source, WordPress-based platform for publishing. Grab posts from your WordPress blog, pull in feeds from external sites, or create new content directly in Anthologize. Then outline, order, and edit your work, crafting it into a coherent volume for export in several formats, including PDF, EPUB, and TEI.
http://anthologize.org
GNU General Public License v3.0
174 stars 28 forks source link

Fix set_include_path() call for epub exports #88

Closed r-a-y closed 9 years ago

r-a-y commented 9 years ago

Hi,

On our nginx set up, we were experiencing a fatal error when attempting to do an epub export:

PHP Fatal error: require_once(): Failed opening required 'PEAR.php' (include_path='.:/usr/share/php:/usr/share/pear:/PATH/wp-content/plugins/anthologize/templates/epub/pear_ext') in /PATH/wp-content/plugins/anthologize/templates/epub/pear_ext/Archive.php on line 38

We narrowed the problem down to set_include_path(), which we addressed by:

  1. Setting the include path to only the pear_ext directory (without prepending the current include path); and by
  2. Moving the set_include_path() call further down the file just before require_once( 'Archive.php' ) is called.

I also tested this on a WAMP stack and this also worked, but might require additional testing on other environments.

boonebgorges commented 9 years ago

Thanks for the PR, @r-a-y. I wonder if we can just drop the use of set_include_path() altogether, and let relative paths do all the work. See 73fa32e. Does this work on your installation?

r-a-y commented 9 years ago

Does this work on your installation?

Unfortunately, that did not work. Got the same fatal error as the above. I haven't delved too deep to see what might be causing the relative path issue though.

boonebgorges commented 9 years ago

Cool, thanks for getting back. I'll check this out in nginx to get a better sense of what's going on.

On 06/17/15 21:47, r-a-y wrote:

Does this work on your installation?

Unfortunately, that did not work. Got the same fatal error as the above. I haven't delved too deep to see what might be causing the relative path issue though.

— Reply to this email directly or view it on GitHub https://github.com/chnm/anthologize/pull/88#issuecomment-113008676.

boonebgorges commented 9 years ago

Really weird. I'm testing on nginx now and it's working fine, so it must be something about the way your PHP is configured or something like that. I don't understand why the include path has to be changed.

Moving the set_include_path() call is no problem, but wiping out the current include path makes me somewhat nervous, just in case any WP code tries to do anything funny after the path has been changed. So I'm wary of making the change without understand it a bit better.

I thought at first that this might be a problem with PHP not allowing overrides (see eg http://blog.calevans.com/2008/02/14/set_include_path-failing/) but this doesn't seem likely, given that set_include_path() does in fact work sometimes.

I'll dig a little more. If I can't find anything, I'll just accept your change and see if anything breaks :)

r-a-y commented 9 years ago

Yeah, I have a feeling it's to do with the PHP set up on the production server as I can't reproduce this locally.

I'll see what I can gather from the production environment and get back to you.

r-a-y commented 9 years ago

Commit 9fc76d0 is more safe and simply moves the 'pear_ext' directory to the beginning in set_include_path(). This fixed things for us as well.

boonebgorges commented 9 years ago

:+1: Thanks, @r-a-y !