Skip to content

Use cURL as a fallback for the Auto-Cache Engine when allow_fopen_url is disabled #440

@raamdev

Description

@raamdev

Some web hosts disable allow_url_fopen in the PHP configuration on the server, which means the ZenCache Auto-Cache Engine will be unable to access the URL to the XML Sitemap (which it uses to figure out which pages it on the site it should generate a cache file for).

As a result, you may see an error like the following in your error log whenever the Auto-Cache Engine runs:

[Wed Mar 04 23:09:25 2015] [warn] [client 185.114.224.0] mod_fcgid: stderr: PHP Warning: XMLReader::open(http://example.com//sitemap_index.xml) [<a href='xmlreader.open'>xmlreader.open</a>]: failed to open stream: no suitable wrapper could be found in /home/example/www/wp-content/plugins/zencache-pro/includes/auto-cache.php on line 233

It should be possible to fetch a URL using cURL (which is more reliable than requiring allow_fopen_url, which many web hosts disable for security reasons) and then load the result into XMLReader().

@jaswsinc writes...

The XMLReader class reads the input XML from a stream, one node at a time. Making it possible for ZC to deal with extremely large (even multi-GB sitemaps). However, I don't see any reason why we couldn't have it open a stream from a local resource that we download via cURL. I'm not certain that will work, but definitely worth taking a look at, I agree.

Referencing: http://php.net/manual/en/xmlreader.open.php
See also: http://php.net/manual/en/xmlreader.read.php

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions