You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Enrico Sorcinelli <e....@pisa.iol.it> on 2003/11/17 19:25:05 UTC

PerlSetVar with '0' value

Hi all,

I have this PerlSetVar behaviour. Suppose to have:

	<Location /foo>
		SetHander perl-script
		PerlSetVar Something 0
		PerlResponseHandler MyModule
	</Location>

But in MyModule.pm, $r->dir_config('Something') returns an undef value instead
of 0 (zero). This happens on both mod_perl generations (I have Perl 5.8.1 with mp
1.29 and mp 1.99_10).
Also I've tried with:

 	PerlSetVar Something '0'
	PerlSetVar Something "0"

My problem is that the my default value of 'Something' isn't 0 and 0 is a
possible value for my module. So, currently I have to code around for example
with:

	PerlSetVar Something none

in order to pass a correspondent 0 value.

Maybe it is a known behaviour, but... I've forgotten something in the docs about
it? :-)

I'm surprise of this, because in my Apache (1.x) C modules experience, TAKE1 (or
TAKE2) directive doesn't have the same behaviour returnig args also with 0
values.

by

	- Enrico

-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: PerlSetVar with '0' value

Posted by Stas Bekman <st...@stason.org>.
Enrico Sorcinelli wrote:
[...]
>>Index: src/modules/perl/Apache.xs
[...]
>>-    if (!SvTRUE(RETVAL)) {
>>+    if (!SvOK(RETVAL)) {
[...]
> Hi Geoff,
> the patch seems to work fine.
> I've applied it over mp 1.29 (with Apache 1.3.28)

Since this is a bug, fixing it is a right thing to do. If someone was relying 
on the bug and didn't tell us that there was a bug, too bad for them. It's not 
like we are breaking API with this fix.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: PerlSetVar with '0' value

Posted by Enrico Sorcinelli <e....@pisa.iol.it>.
On Tue, 25 Nov 2003 15:47:07 -0500
Geoffrey Young <ge...@modperlcookbook.org> wrote:

> > I'll
> > take a look at 1.0 "soonish" 
> 
> it looks like the logic is pretty much the same in 1.0 as well.
> 
> please try this (untested) patch and let me know if it fixes things for you.
> 
> --Geoff
> 
> Index: src/modules/perl/Apache.xs
> ===================================================================
> RCS file: /home/cvspublic/modperl/src/modules/perl/Apache.xs,v
> retrieving revision 1.129
> diff -u -r1.129 Apache.xs
> --- src/modules/perl/Apache.xs  16 Sep 2003 19:51:06 -0000      1.129
> +++ src/modules/perl/Apache.xs  25 Nov 2003 20:39:41 -0000
> @@ -2084,7 +2084,7 @@
>                                                  &perl_module);
>         TABLE_GET_SET(c->vars, FALSE);
>      }
> -    if (!SvTRUE(RETVAL)) {
> +    if (!SvOK(RETVAL)) {
>         s = r && r->server ? r->server : perl_get_startup_server();
>         if (s && s->module_config) {
>             SvREFCNT_dec(RETVAL); /* in case above did newSV(0) */
> 

Hi Geoff,
the patch seems to work fine.
I've applied it over mp 1.29 (with Apache 1.3.28)

Thanks

by

	- Enrico


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: PerlSetVar with '0' value

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> I'll
> take a look at 1.0 "soonish" 

it looks like the logic is pretty much the same in 1.0 as well.

please try this (untested) patch and let me know if it fixes things for you.

--Geoff

Index: src/modules/perl/Apache.xs
===================================================================
RCS file: /home/cvspublic/modperl/src/modules/perl/Apache.xs,v
retrieving revision 1.129
diff -u -r1.129 Apache.xs
--- src/modules/perl/Apache.xs  16 Sep 2003 19:51:06 -0000      1.129
+++ src/modules/perl/Apache.xs  25 Nov 2003 20:39:41 -0000
@@ -2084,7 +2084,7 @@
                                                 &perl_module);
        TABLE_GET_SET(c->vars, FALSE);
     }
-    if (!SvTRUE(RETVAL)) {
+    if (!SvOK(RETVAL)) {
        s = r && r->server ? r->server : perl_get_startup_server();
        if (s && s->module_config) {
            SvREFCNT_dec(RETVAL); /* in case above did newSV(0) */


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: PerlSetVar with '0' value

Posted by Enrico Sorcinelli <e....@pisa.iol.it>.
On Tue, 25 Nov 2003 15:34:16 -0500
Geoffrey Young <ge...@modperlcookbook.org> wrote:

> Enrico Sorcinelli wrote:
> > Hi all,
> >> 
> > I have this PerlSetVar behaviour. Suppose to have:
> > 
> > 	<Location /foo>
> > 		SetHander perl-script
> > 		PerlSetVar Something 0
> > 		PerlResponseHandler MyModule
> > 	</Location>
> > 
> > But in MyModule.pm, $r->dir_config('Something') returns an undef value instead
> > of 0 (zero). This happens on both mod_perl generations (I have Perl 5.8.1 with mp
> > 1.29 and mp 1.99_10).
> 
> this is fixed in current mod_perl 2.0 cvs - please give it a whirl.  

Thanks, I'll do it.

> I'll take a look at 1.0 "soonish" but it may never get fixed there, depending 
> on how intricate the change is.  we want to fix bugs, of course, but we also
> don't want to upset the stable tree for little things, so we treat it with
> much more care :)

Yes, I know :-)
If this little fix will not be inserted in the mp1 tree, there isn't problem:
I'll apply the patch locally, where necessary.

by

	- Enrico


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: PerlSetVar with '0' value

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Enrico Sorcinelli wrote:
> Hi all,
> 
> I have this PerlSetVar behaviour. Suppose to have:
> 
> 	<Location /foo>
> 		SetHander perl-script
> 		PerlSetVar Something 0
> 		PerlResponseHandler MyModule
> 	</Location>
> 
> But in MyModule.pm, $r->dir_config('Something') returns an undef value instead
> of 0 (zero). This happens on both mod_perl generations (I have Perl 5.8.1 with mp
> 1.29 and mp 1.99_10).

this is fixed in current mod_perl 2.0 cvs - please give it a whirl.  I'll
take a look at 1.0 "soonish" but it may never get fixed there, depending on
how intricate the change is.  we want to fix bugs, of course, but we also
don't want to upset the stable tree for little things, so we treat it with
much more care :)

--Geoff


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: PerlSetVar with '0' value

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Enrico Sorcinelli wrote:
> Hi all,
> 
> I have this PerlSetVar behaviour. Suppose to have:
> 
> 	<Location /foo>
> 		SetHander perl-script
> 		PerlSetVar Something 0
> 		PerlResponseHandler MyModule
> 	</Location>
> 
> But in MyModule.pm, $r->dir_config('Something') returns an undef value instead
> of 0 (zero). This happens on both mod_perl generations (I have Perl 5.8.1 with mp
> 1.29 and mp 1.99_10).

hmm.  PerlSetVar uses apache tables, so I'm not sure whether the problem is 
with mod_perl or apache's internal treatment of 0 in C land and the 
subsequent perl translation.  but I'll look into it for you next week. 
thanks for reporting it.

> 
> I'm surprise of this, because in my Apache (1.x) C modules experience, TAKE1 (or
> TAKE2) directive doesn't have the same behaviour returnig args also with 0
> values.

this uses a completely different mechanism :)

--Geoff


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html