I have the getID3 PHP library installed at the include path set in php.ini, but the module does not try to include the file. Instead it attempts to physically locate the file from a relative path (with file_exists), which of course does not work.

The include path can be searched with fopen, by setting the third argument to TRUE. fopen should be preceded by a @ to suppress errors if the library does not exist.

Comments

drewish’s picture

Are you filling in the path in the settings page?

cburschka’s picture

The include path is set to .:/path-to-php/scripts, and the getid3 files are in /path-to-php/scripts/getid3. This means it is possible to include them with getid3/getid3.php, so I set the directory getid3 in the settings page.

Of course I don't enter the whole include path, since that may well change. The point of the include path is that you set it only once in php.ini...

If you use @fopen($getid3_path . '/getid3.php', 'r', TRUE), then you will find it if it can be included. file_exists does not work in that it does not find files even though they are includeable. Unfortunately PHP does not have a dedicated is_includeable() function for this.

drewish’s picture

why do you have to rely on the the include path? just put the path into the module's settings and be done with it.

cburschka’s picture

Well, as said, the point is that I want to avoid changing the setting on every single site if the include path changes again. ;)

RobLoach’s picture

So if you set the GetID3 path to an empty string, it doesn't find it? If you get it working, Andrew and I would love a patch....

cburschka’s picture

It doesn't. The problem is that the module uses file_exists to check for the PHP file, and file_exists only looks in the path you give it. This is pretty cumbersome. The alternatives are either including with @include, or opening with @fopen($path, 'r', TRUE), or checking the include path manually by using foreach(explode(":", get_include_path()) as $path). I got it to work using @fopen, but I'm not sure which would be preferable.

drewish’s picture

Status: Active » Closed (won't fix)

i'm marking this as won't fix unless someone want's to submit a patch. i really don't think it's a big deal.