Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
drewish CreditAttribution: drewish commentedAre you filling in the path in the settings page?
Comment #2
cburschkaThe 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 withgetid3/getid3.php
, so I set the directorygetid3
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.Comment #3
drewish CreditAttribution: drewish commentedwhy do you have to rely on the the include path? just put the path into the module's settings and be done with it.
Comment #4
cburschkaWell, as said, the point is that I want to avoid changing the setting on every single site if the include path changes again. ;)
Comment #5
RobLoachSo 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....
Comment #6
cburschkaIt 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.
Comment #7
drewish CreditAttribution: drewish commentedi'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.