Custom directive and <Location> - bug?

Custom directive and <Location> - bug?

am 30.11.2010 13:51:51 von ajgb

Hi,

I've noticed that when using custom directives within nested
the result of $r->location reports the parent one only, instead of the
subdir.

However if I add PerlSetVar the $r->location will report the correct one.

The way to replicate:
please follow the example
http://perl.apache.org/docs/2.0/user/config/custom.html#Merg ing_at_Work

and now add:

--- httpd.conf-orig 2010-11-30 12:06:57.491843181 +0000
+++ httpd.conf 2010-11-30 12:07:39.217629859 +0000
@@ -18,6 +18,7 @@
PerlResponseHandler MyApache2::CustomDirectivesTest


+ PerlSetVar fix "problem"
MyPlus 1
MyList "SubDir"
MyAppend "SubDir"


--- MyApache2-orig/CustomDirectivesTest.pm 2010-11-30
12:03:13.430774397 +0000
+++ MyApache2/CustomDirectivesTest.pm 2010-11-30 12:04:58.655364262 +0000
@@ -39,6 +39,8 @@

$r->printf("Processing by %s.\n",
$s->is_virtual ? "virtual host" : "main server");
+ $r->printf("\$r->$_: %s\n", $r->$_)
+ for qw( uri location path_info );

for my $sec (sort keys %secs) {
$r->print("\nSection $sec\n");


So when run the output with PerlSetVar is:
# r->uri: /custom_directives_test/subdir
# r->location: /custom_directives_test/subdir
# r->path_info: /subdir

while without:
# r->uri: /custom_directives_test/subdir
# r->location: /custom_directives_test
# r->path_info: /subdir


This has been tested on perl 5.12.2:
Apache/2.2.16 + mod_perl/2.0.4
Apache/2.2.17 + mod_perl/2.0.5-dev (20101111091957)
Apache/2.2.17 + mod_perl/2.0.5-dev (20101130091946)


Cheers,
Alex

Re: Custom directive and <Location> - bug?

am 06.12.2010 21:39:42 von gozer

This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig9DC03989B768DB5A2B4935F3
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 10-11-30 07:51 , "Alex J. G. Burzyński" wrote:
> Hi,
>=20
> I've noticed that when using custom directives within nested =

> the result of $r->location reports the parent one only, instead of the
> subdir.
>=20
> However if I add PerlSetVar the $r->location will report the correct on=
e.

Yup, you've stumbled on an interesting bug.

> The way to replicate:
> please follow the example
> http://perl.apache.org/docs/2.0/user/config/custom.html#Merg ing_at_Work=

>=20
> and now add:
>=20
> --- httpd.conf-orig 2010-11-30 12:06:57.491843181 +0000
> +++ httpd.conf 2010-11-30 12:07:39.217629859 +0000
> @@ -18,6 +18,7 @@
> PerlResponseHandler MyApache2::CustomDirectivesTest
>

>
> + PerlSetVar fix "problem"
> MyPlus 1
> MyList "SubDir"
> MyAppend "SubDir"

The reason this makes a difference is that without it, there are no
mod_perl directives (the custom ones are 'special'), so no configuration
pass for modperl in that directory.

Side-effect of that is that $r->location isn't tracked proprely.
Keep in mind that r->location is not an httpd api, but rather something
convenient mod_perl tracks. But not in this case, unfortunately.

--=20
Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/ m/gozer\@(apache|cpan|ectoplasm)\.org/


--------------enig9DC03989B768DB5A2B4935F3
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkz9Sg4ACgkQyzKhB4jDpaWIRwCfTyOhBX+znZG313q2P2U5 Hk7i
v+MAni6yjbdYcyLn4w6RKrc+WhWKquNH
=XqGT
-----END PGP SIGNATURE-----

--------------enig9DC03989B768DB5A2B4935F3--

Re: Custom directive and <Location> - bug?

am 06.12.2010 22:33:39 von ajgb

On 06/12/10 20:39, Philippe M. Chiasson wrote:
> On 10-11-30 07:51 , "Alex J. G. Burzyński" wrote:
>> Hi,
>>
>> I've noticed that when using custom directives within nested
>> the result of $r->location reports the parent one only, instead of the
>> subdir.
>>
>> However if I add PerlSetVar the $r->location will report the correct one.
> Yup, you've stumbled on an interesting bug.
>

I've found this while working on Apache2::Layer (on cpan)

>> The way to replicate:
>> please follow the example
>> http://perl.apache.org/docs/2.0/user/config/custom.html#Merg ing_at_Work
>>
>> and now add:
>>
>> --- httpd.conf-orig 2010-11-30 12:06:57.491843181 +0000
>> +++ httpd.conf 2010-11-30 12:07:39.217629859 +0000
>> @@ -18,6 +18,7 @@
>> PerlResponseHandler MyApache2::CustomDirectivesTest
>>

>>
>> + PerlSetVar fix "problem"
>> MyPlus 1
>> MyList "SubDir"
>> MyAppend "SubDir"
> The reason this makes a difference is that without it, there are no
> mod_perl directives (the custom ones are 'special'), so no configuration
> pass for modperl in that directory.
>
> Side-effect of that is that $r->location isn't tracked proprely.
> Keep in mind that r->location is not an httpd api, but rather something
> convenient mod_perl tracks. But not in this case, unfortunately.
>

If you take a look at those (around lines 68-70):
http://pastebin.com/PUtcczwA (with PerlSetVar)
http://pastebin.com/kfjMtZsT (without PerlSetVar)

you'll see that PerlSetVar creates directory context, while custom
directive on its own does not.


However the Apache2::CmdParams->path returns the correct value and
that's what I'm using in my module as a workaround.

Thanks,
Alex