Philippe M. Chiasson wrote:
Stas Bekman wrote:
Philippe M. Chiasson wrote:
from todo/release :
* the following methods/functions are using compat implementations in tests and should use the real 2.0 API: method_register, server_root_relative
As far as I can see, this is not the case anymore, so should we remove that entry ? Or am I missing something ?
I'm not sure about method_register, since it didn't exist in 1.0. I think both has to do with the pool argument. Since method_register is now $s->method_register, there is no problem with it indeed.
As for server_root_relative, there is still an issue with it. Since we have the pool problem with this method, I've documented it as deprecated
and inefficient (since it copies the returned string, just in case). I've suggested to use:
File::Spec->catfile(Apache::ServerUtil::server_root, @_);
as a better solution. One thing I've missed, and Geoff (as usual) has corrected me, is that it doesn't cover the case when the argument $_[0] is already a full path instead of relative. This is an undocumented feature as far as Apache docs go.
So back to the compat issue. At the moment lib/Apache/compat.pm has:
sub server_root_relative { my $class = shift; File::Spec->catfile(Apache::ServerUtil::server_root, @_); }
which doesn't cover that special case. I suppose before doing catfile we need to check whether $_[0] is already absolute, in which case we should not concat server_root in.
So would this patch resolve this open issue ?
Forgot to include test with the patch:
-- -------------------------------------------------------------------------------- Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5 http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
Index: lib/Apache/compat.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v
retrieving revision 1.114
diff -u -I$Id -r1.114 compat.pm
--- lib/Apache/compat.pm 24 Jul 2004 07:27:03 -0000 1.114
+++ lib/Apache/compat.pm 9 Aug 2004 21:04:05 -0000
@@ -249,8 +249,13 @@
package Apache;
sub server_root_relative {
- my $class = shift;
- File::Spec->catfile(Apache::ServerUtil::server_root, @_);
+ my ($class, $path, @extra) = @_;
+ if (File::Spec->file_name_is_absolute($path)) {
+ return File::Spec->catfile($path, @extra);
+ }
+ else {
+ File::Spec->catfile(Apache::ServerUtil::server_root, $path, @extra);
+ }
}
sub exit {
Index: t/response/TestCompat/apache.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestCompat/apache.pm,v
retrieving revision 1.16
diff -u -I$Id -r1.16 apache.pm
--- t/response/TestCompat/apache.pm 16 Jul 2004 01:10:46 -0000 1.16
+++ t/response/TestCompat/apache.pm 9 Aug 2004 21:04:05 -0000
@@ -17,7 +17,7 @@
sub handler {
my $r = shift;
- plan $r, tests => 16;
+ plan $r, tests => 17;
$r->send_http_header('text/plain');
@@ -86,6 +86,10 @@
ok t_filepath_cmp(canonpath(Apache->server_root_relative),
canonpath($server_root),
'Apache->server_root_relative()');
+
+ ok t_filepath_cmp(canonpath(Apache->server_root_relative('/tmp')),
+ canonpath('/tmp'),
+ "Apache->server_root_relative('/tmp')");
}
OK;
signature.asc
Description: OpenPGP digital signature
