# extension_path not used for zend_extension

- Thread: https://externals.io/message/51927
- Original archive: https://news-web.php.net/php.internals/51927
- Started by Ferenc Kovacs on 2011-04-18T15:04:40+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #51927 — Ferenc Kovacs — 2011-04-18T15:04:40+00:00

URL: https://externals.io/message/51927#51927

Hi.

I've just noticed that in spite of the documentation, one can (try to) load
a zend_extension via a relative path.
http://www.php.net/manual/en/ini.core.php#ini.zend-extension
<http://www.php.net/manual/en/ini.core.php#ini.zend-extension>the only thing
preventing that from working is that the extension_dir isn't used searching
for the lib.

you can see that extension uses the extension_dir correctly:

tyrael@devel-tyrael:~$ strace php -n -d extension=xdebug.so -v 2>&1|grep
xdebug
execve("/usr/bin/php", ["php", "-n", "-d", "extension=xdebug.so", "-v"], [/*
16 vars */]) = 0
open("/usr/lib/php5/20090626/xdebug.so", O_RDONLY) = 3

and zend_extension not, hence it cannot load the lib.

tyrael@devel-tyrael:~$ strace php -n -d zend_extension=xdebug.so -v
2>&1|grep xdebug
execve("/usr/bin/php", ["php", "-n", "-d", "zend_extension=xdebug.so",
"-v"], [/* 16 vars */]) = 0
open("/lib/tls/x86_64/xdebug.so", O_RDONLY) = -1 ENOENT (No such file or
directory)
open("/lib/tls/xdebug.so", O_RDONLY)    = -1 ENOENT (No such file or
directory)
open("/lib/x86_64/xdebug.so", O_RDONLY) = -1 ENOENT (No such file or
directory)
open("/lib/xdebug.so", O_RDONLY)        = -1 ENOENT (No such file or
directory)
open("/usr/lib/tls/x86_64/xdebug.so", O_RDONLY) = -1 ENOENT (No such file or
directory)
open("/usr/lib/tls/xdebug.so", O_RDONLY) = -1 ENOENT (No such file or
directory)
open("/usr/lib/x86_64/xdebug.so", O_RDONLY) = -1 ENOENT (No such file or
directory)
open("/usr/lib/xdebug.so", O_RDONLY)    = -1 ENOENT (No such file or
directory)
open("/lib/x86_64-linux-gnu/tls/x86_64/xdebug.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
open("/lib/x86_64-linux-gnu/tls/xdebug.so", O_RDONLY) = -1 ENOENT (No such
file or directory)
open("/lib/x86_64-linux-gnu/x86_64/xdebug.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
open("/lib/x86_64-linux-gnu/xdebug.so", O_RDONLY) = -1 ENOENT (No such file
or directory)
open("/usr/lib/x86_64-linux-gnu/tls/x86_64/xdebug.so", O_RDONLY) = -1 ENOENT
(No such file or directory)
open("/usr/lib/x86_64-linux-gnu/tls/xdebug.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
open("/usr/lib/x86_64-linux-gnu/x86_64/xdebug.so", O_RDONLY) = -1 ENOENT (No
such file or directory)
open("/usr/lib/x86_64-linux-gnu/xdebug.so", O_RDONLY) = -1 ENOENT (No such
file or directory)
write(2, "Failed loading xdebug.so:  xdebug"..., 96Failed loading xdebug.so:
 xdebug.so: cannot open shared object file: No such file or directory

if you have the lib in you LD path, or you set the LD_LIBRARY_PATH, it will
obviously load the lib from the relative path.

tyrael@devel-tyrael:~$ LD_LIBRARY_PATH=/usr/lib/php5/20090626/ strace php -n
-d zend_extension=xdebug.so -v 2>&1|grep xdebug
execve("/usr/bin/php", ["php", "-n", "-d", "zend_extension=xdebug.so",
"-v"], [/* 17 vars */]) = 0
open("/usr/lib/php5/20090626/xdebug.so", O_RDONLY) = 3

so I think we should either make sure that the zend_extension is an absolute
path, or we should use the extension_path and allow loading zend extensions
without the need to screw around with the LD path.

what do you think?

Tyrael

---

## #51928 — johannes@schlueters.de — 2011-04-18T15:24:25+00:00

URL: https://externals.io/message/51927#51928 · In reply to: #51927

> Hi.
>
> I've just noticed that in spite of the documentation, one can (try to) load
> a zend_extension via a relative path.
> http://www.php.net/manual/en/ini.core.php#ini.zend-extension
> <http://www.php.net/manual/en/ini.core.php#ini.zend-extension>the only thing
> preventing that from working is that the extension_dir isn't used searching
> for the lib.

zend_extension's are a feature of the engine. extension_dir is a feature 
from PHP's main, this means the engine doesn't know about it.

I agree that usablity-wise it's nice if that's moved around ...

johannes

---

## #51930 — Ferenc Kovacs — 2011-04-18T16:06:44+00:00

URL: https://externals.io/message/51927#51930 · In reply to: #51928

2011/4/18 Johannes Schlüter <johannes@schlueters.de>

>
>
> 
>
> > […]
>
> zend_extension's are a feature of the engine. extension_dir is a feature
> from PHP's main, this means the engine doesn't know about it.
>
> I agree that usablity-wise it's nice if that's moved around ...
>
> johannes
>

thanks for the clarification.
if thats the only thing thats preventing this to work (eg. someone has to
patch the engine to be aware of the extension_dir), then I think I should
open a feature request for this.

Tyrael

---

## #51934 — Ferenc Kovacs — 2011-04-18T21:08:06+00:00

URL: https://externals.io/message/51927#51934

2011/4/18 Johannes Schlüter <johannes@schlueters.de>

>
>
> 
>
>  thanks for the clarification.
> > […]
>
> slight semantic comment: "to patch the engine to be aware of the
> extension_dir" -> "to patch the engine to make extension_dir an engine
> thing".
>
> In theory you can build the engine stand-alone, without PHP and therefore
> can not depend on anything outside the engine (except TSRM, which then again
> doesn't depend on PHP).
>
> johannes
>

I see, thanks for the clarification.
I opened a ticket for this, feel free to comment it.
http://bugs.php.net/bug.php?id=54564&

Tyrael
