nategood/httpful

Problem when using open_basedir and multiple installations

nublaii opened this issue · 0 comments

Hi, I don't know if there is a way of fixing this from your end, since I believe it's a bug on opcode, but it's fixable if you modify the source code.

I have multiple websites using httpful, and each one of them has open_basedir defined to their respective root.

I'm running ubuntu 14.04 with stock php (v 5.5.9) with OPcache v7.0.3 (also stock version)

I include httpful.phar this way:

use Httpful\Request;
if ( ! class_exists( '\Httpful\Request' ) ) {
    include_once( REDIRECT_DIR . '/vendor/httpful.phar' );
}

This is executed on a particular page on multiple websites, each with its own httpful.phar.

I restart apache, and after hitting that page, it works as expected.

When I hit the second page I get open_basedir errors, because the first site tries to use the compiled version (opcache's version), that points to the first website.

If you check this page you can see the only comment that talks about this issue: http://php.net/manual/en/phar.mapphar.php

I know it's opcache's problem, but I found out that if you modify the Bootstrap.php file, line 54, and modify it to point to the full path of the phar file, it works as expected.

self::_autoload('phar://httpful.phar', $classname);

to

self::_autoload('phar:///full/path/on/the/server/httpful.phar', $classname);

Is there any way of self-referencing the file from inside httpful that uses the realpath of the file instead of relative?