Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Attempting to require() or include() a vfsStream file dies silently #22

Closed
mrtorrent opened this Issue Oct 3, 2011 · 4 comments

Comments

Projects
None yet
2 participants

Hi, I'm trying to use vfsStream to mock the target of a require/include call in a PHPUnit test, but it just dies silently. I've tried setting error reporting to E_ALL and turning on allow_url_include both at runtime and in php.ini. I've searched and found only a PHP bug report with a snarky developer answer and a StackOverflow question with no answer.

Any help tracking this down would be much appreciated.

Owner

mikey179 commented Oct 3, 2011

I've answered the question over at StackOverflow, it seems to stem from a wrong understanding of the create() method.

@mikey179 mikey179 closed this Oct 3, 2011

Hi Frank, thank you for the quick response. I see what you mean about the
stackoverflow questioner not using create() properly, but I'm not using
create and I believe I've set up the structure correctly and am using the
right URL. Here's a simplified version of the code I'm using:

    vfsStream::setup('mockWordpress');
    $file = new vfsStreamFile('file.php');
    $file->write('some data');
    vfsStreamWrapper::getRoot()->addChild($file);
    require_once(vfsStream::url('mockWordpress') . DIRECTORY_SEPARATOR .

'file.php');

Let me know if you see any errors in that, maybe there's something I keep
missing.

Cheers,

Miquel

On Oct 3, 2011 6:06 PM, "Frank Kleine" <
reply@reply.github.com>
wrote:

I've answered the question over at StackOverflow, it seems to stem from a
wrong understanding of the create() method.

Reply to this email directly or view it on GitHub:
#22 (comment)

@mikey179 mikey179 reopened this Oct 4, 2011

Owner

mikey179 commented Oct 4, 2011

Did you enable allow_url_fopen? allow_url_include only works if allow_url_fopen is also enabled, see http://www.php.net/manual/filesystem.configuration.php#ini.allow-url-include. Otherwise, which version of PHP do you use? Do you have Suhosin enabled?

Ah-ha, it was Suhosin. I added vfs:// to its whitelist like so:

suhosin.executor.include.whitelist = "vfs://"

...and require/include now work. Interestingly, when running suhosin the
values of allow_url_fopen and allow_url_include seem to be totally ignored.
Once I had added the above whitelist entry, I could disable both and still
include the vfsStream file.

Many thanks for your assistance.

Miquel

On Tue, Oct 4, 2011 at 10:42 AM, Frank Kleine <
reply@reply.github.com>wrote:

Did you enable allow_url_fopen? allow_url_include only works if
allow_url_fopen is also enabled, see
http://www.php.net/manual/filesystem.configuration.php#ini.allow-url-include.
Otherwise, which version of PHP do you use? Do you have Suhosin enabled?

Reply to this email directly or view it on GitHub:
#22 (comment)

@mikey179 mikey179 closed this Oct 4, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment