I'm steadily making progress with getting a collection of mod_perl 1 compatibale scripts working with mod_perl 2 using the backward compatibility mode.
However, I find that the working directory of all scripts is "/". This occurs for both ModPerl::Registry and Apache::Registry. This causes many scripts to fail because they call open() using a relative pathname.
Surely the working directory of a script should be the directory in which it resides?
It does not seem to matter what directory I am in when I invoke httpd; the script's current directory is always "/".
That's correct. This is because $r->chdir_file in compat doesn't do anything.
The reason is that under threaded mpm, chdir() affects all threads. Of course we could check whether the mpm is prefork and do things the old way, but that means that the same code won't work the same under threaded and non-threaded mpms. Hence the limbo. Still waiting for Arthur to finish porting safecwd package, which should resolve this problem.
Meanwhile try this patch:
Index: lib/Apache/compat.pm =================================================================== RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v retrieving revision 1.86 diff -u -r1.86 compat.pm --- lib/Apache/compat.pm 28 Jul 2003 10:33:58 -0000 1.86 +++ lib/Apache/compat.pm 29 Jul 2003 11:19:46 -0000 @@ -335,6 +335,8 @@
sub chdir_file { #XXX resolve '.' in @INC to basename $r->filename + my $dir = @_ == 2 ? $_[1] : $_[0]->filename; + chdir $dir; }
sub finfo {
I won't commit it yet, but you can override it in your startup.pl, until the dust settles down:
require Apache::compat; sub Apache::RequestRec::chdir_file { my $dir = @_ == 2 ? $_[1] : $_[0]->filename; chdir $dir; }
__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com