Discussion:
PHP testing - problem with php libraries loading
Filin A.
2005-11-19 22:27:24 UTC
Permalink
Hi all.

I'm trying to use Apache::Test module for testing my
php driven site
(Linux, Apache 2.0, PHP 4.3).

Everything works pretty good, but when I try to test a
php page which uses any
of mysql functions - the test fails and the error_log
contains these lines:

...
PHP Warning: Unknown(): Unable to load dynamic
library './mysql.so' - ./mysql.so: cannot open shared
object file: No such file or directory in Unknown on
line 0
PHP Warning: Unknown(): Unable to load dynamic
library './xmlrpc.so' - ./xmlrpc.so: cannot open
shared object file: No such file or directory in
Unknown on line 0
...
[Client 127.0.0.1] PHP Fatal error: Call to
undefined function: mysql_connect() in
/home/filin/work-varavka/staff/htdocs/_inc/dbconnect.inc.php
on line 8
...

I think a line in the t/conf/php.ini:

extension_dir = "./"

means that php seeks libraries in the current
directory, while those
libraries are in the /usr/lib/php4/. Thereby I have 2
questions:
1) Why it is necessary to have a special php.ini for
testing?
2) How can I test (in a sane manner) php code with
functions from
dynamic libraries?

I've tried to copy mysql.so in the "current
directory", in all
meanings of "current" which I could imagine but
without any success.
I've successfully tried to modify the
Apache::TestConfigPHP
so that it generates now
'extension_dir="/usr/lib/php4/"',
but I don't think it is a good solving...


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Geoffrey Young
2005-11-20 01:36:25 UTC
Permalink
cc'ing chris :)
Post by Filin A.
extension_dir = "./"
means that php seeks libraries in the current
directory, while those
libraries are in the /usr/lib/php4/.
hmm, could be. chris would know better.
Post by Filin A.
Thereby I have 2
1) Why it is necessary to have a special php.ini for
testing?
for the same reason that Apache-Test maintains all its own configuration
files, really - consistency, principle of least surprise, and so on. think
of it like this...

say you have code that works one system and doesn't work on another. the
problem turns out to be that your php.ini file contains a crucial
difference, but one you didn't think was crucial. if your tests relied on
the installed php.ini file then you'd have the exact same problem on each
box when running the tests, on one box it would fail and on one box it would
pass. this is Very Bad from a testing point of view - tests should create a
very specific environment in which to exercise your code, one where all the
variables are known.

using our own php.ini file (and own httpd.conf, etc) means that the
described circumstance would never happen - the tests would pass on both
systems letting you know immediately that your production environment is
_not_ the same as your testing environment. and that is Good from a testing
point of view.
Post by Filin A.
2) How can I test (in a sane manner) php code with
functions from
dynamic libraries?
I don't know the specifics, but to alter any php.ini setting you would
create t/conf/extra.conf.in and use a php variable to override the default
settings in php.ini
Post by Filin A.
I've tried to copy mysql.so in the "current
directory", in all
meanings of "current" which I could imagine but
without any success.
I've successfully tried to modify the
Apache::TestConfigPHP
so that it generates now
'extension_dir="/usr/lib/php4/"',
but I don't think it is a good solving...
no, anything you need to override you can do locally from t/extra.conf.in,
such as

<IfModule @PHP_MODULE>
php_extension_dir /usr/lib/php4/
</IfModule>

or somesuch - I'm not really a php guy :)

chris has links to the sample tarball where you can see tricks like this in
action. unfortunately we haven't had the free tuits to document it as well
as we would have liked. but then again, nobody seemed to be using the php
side of things but us. so, welcome - we hope you like it :)

--Geoff
Filin A.
2005-11-25 22:13:48 UTC
Permalink
Hi. Sorry for not writing sooner and thanks for your
quick responce.
Post by Geoffrey Young
Post by Filin A.
1) Why it is necessary to have a special php.ini
for
Post by Geoffrey Young
Post by Filin A.
testing?
say you have code that works one system and doesn't
work on another.
Post by Geoffrey Young
the problem turns out to be that your php.ini file
contains a crucial
Post by Geoffrey Young
difference, but one you didn't think was crucial.
I see...
Post by Geoffrey Young
no, anything you need to override you can do locally
from
Post by Geoffrey Young
t/extra.conf.in,
such as
php_extension_dir /usr/lib/php4/
</IfModule>
But I can't! I've tride a lot of variants and I even
think that

<IfModule @PHP_MODULE@>
php_admin_value extension_dir /usr/lib/php4/
</IfModule>

_should_ work - but it doesn't! I don't know why :(
(I tried both t/extra.conf.in and
t/conf/extra.conf.in)
Post by Geoffrey Young
chris has links to the sample tarball where you can
see tricks like
Post by Geoffrey Young
this in action.
Oh. And can you please anyhow lead me at those links?
Post by Geoffrey Young
unfortunately we haven't had the free tuits to
document it as well
Post by Geoffrey Young
as we would have liked. but then again, nobody
seemed to be using the
Post by Geoffrey Young
php side of things but us. so, welcome - we hope
you like it :)

Yes, I do like it. Actualy I'm rather fascinated by
the versality
and power of your testing suit.


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Chris Shiflett
2005-11-28 04:49:24 UTC
Permalink
Hi Filin,
I've tride a lot of variants and I even think that
php_admin_value extension_dir /usr/lib/php4/
</IfModule>
_should_ work - but it doesn't! I don't know why :(
(I tried both t/extra.conf.in and
t/conf/extra.conf.in)
The latter is the correct place.

You might try getting rid of the conditional statement, just to see if
that's the problem.

By the way, how are you testing to see whether this works? Is it the
output of phpinfo()?
Oh. And can you please anyhow lead me at those links?
http://shiflett.org/apache-test-demo.tar.gz
Yes, I do like it. Actualy I'm rather fascinated by
the versality and power of your testing suit.
Very happy to hear this. :-) Hopefully we can help you get this problem
solved.

Chris
Geoffrey Young
2005-11-28 18:08:39 UTC
Permalink
Post by Chris Shiflett
Hi Filin,
I've tride a lot of variants and I even think that
php_admin_value extension_dir /usr/lib/php4/
</IfModule>
_should_ work - but it doesn't! I don't know why :(
(I tried both t/extra.conf.in and
t/conf/extra.conf.in)
The latter is the correct place.
You might try getting rid of the conditional statement, just to see if
that's the problem.
hmm, that's a good point. t/conf/extra.conf.in only affects php tests that
run inside the server, such as t/response/TestAPI/foo.php. if you're using
t/foo.php-style tests then settings in t/conf/extra.conf.in don't apply.
guess we need to figure out how to do that...

--Geoff
Filin A.
2005-11-29 22:28:27 UTC
Permalink
Hi.
Post by Geoffrey Young
hmm, that's a good point. t/conf/extra.conf.in only
affects php tests
Post by Geoffrey Young
that
run inside the server, such as
t/response/TestAPI/foo.php.

Nope. My test is in the t/response/TestPHP/
Post by Geoffrey Young
You might try getting rid of the conditional
statement, just to see if
that's the problem.
Nope. Removing of the condition doesn't solve the
problem :(
Post by Geoffrey Young
By the way, how are you testing to see whether this
works? Is it the
output of phpinfo()?
Mm.. actually I just looked into the error_log...
But after I read your question I made an experiment
whith my
system httpd.conf and php.ini and checked phpinfo()
output.

I've set the extension_dir in php.ini to the wrong
directory
and assigned correct value in the httpd.conf.
It's strange but though phpinfo() acknowledges my
httpd.conf extension_dir as
a 'Local Value', extensions are not loaded.

It looks like settig the extension_dir in a httpd.conf
(or in an extra.conf.in) just don't work with my PHP
4.3.4 :(

I would appreciate your consideration...

--
Filin


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Chris Shiflett
2005-11-30 17:02:59 UTC
Permalink
Post by Filin A.
But after I read your question I made an experiment
whith my system httpd.conf and php.ini and checked
phpinfo() output.
I've set the extension_dir in php.ini to the wrong
directory and assigned correct value in the
httpd.conf. It's strange but though phpinfo()
acknowledges my httpd.conf extension_dir as a
'Local Value', extensions are not loaded.
That rules out Apache-Test as the root cause of the problem. If I were
trying to debug this, I'd very carefully compare the output of phpinfo()
in an environment that works with the output of phpinfo() in an
environment that doesn't.

Hope that helps.

Chris
--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/
Loading...