You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Mark Stosberg <ma...@summersault.com> on 2004/02/28 17:41:16 UTC

Help requested with CGI.pm/Data::FormValidator/modperl bug

Hello,

I maintain the popular Data::FormValidator module, and am just starting
to use modperl myself. A couple of my users spotted a modperl-related
bug in the module. I've read the "CGI porting" document about basic
modperl traps, but I can't figure this out. 

I have a test script for the issue below. When run with "-X", it gives a
different result on the second load. However, I'm not aware of global
variables in use, and I'm not getting the "won't stay shared warning".    

Any pointers to help debug this will be appreciated by myself and the
other DFV/modperl users.

BTW, the issue only happens with a CGI.pm object as input. Using a regular hashref 
doesn't trigger it.

Thanks!

	Mark

-- 
http://mark.stosberg.com/ 

###########################

#!/usr/bin/perl -w

use strict;
use CGI;
use Data::FormValidator;
use Data::Dumper;

my $r = Data::FormValidator->check(CGI->new('note=2003'), {required=>[qw(note)]});

print "Content-type: text/html\n\n";
print "reality check: ".`date`;

print "<pre>". Dumper('r',$r).'</pre><p>';

if (ref  $r->valid('note') eq 'ARRAY' ) {
      print "note is arrayref (but shouldn't be)";
 }
 else {
     print "note isn't arrayref  (correct)";
 }

exit;

######################

First load:

reality check: Sat Feb 28 11:28:56 EST 2004

$VAR1 = 'r';
$VAR2 = bless( { 
                 'profile' => {
                                'defaults' => {},
                                'dependencies' => {},
                                'dependency_groups' => {},
                                'constraints' => {},
                                'constraint_regexp_map' => {},
                                'required' => [ 
                                                'note'
                                              ],
                                'require_some' => {},
                                'field_filter_regexp_map' => {},
                                'field_filters' => {}
                              },
                 'validate_invalid' => [],
                 '__INPUT_DATA' => bless( { 
                                            '.parameters' => [ 
                                                               'note'
                                                             ],
                                            '.charset' => 'ISO-8859-1',
                                            '.r' => bless( do{\(my $o = 137736244)}, 'Apache' ),
                                            '.fieldnames' => {},
                                            'note' => [ 
                                                        '2003'
                                                      ],
                                            'escape' => 1
                                          }, 'CGI' ),
                 'unknown' => {},
                 'missing' => {},
                 'valid' => { 
                              'note' => '2003'
                            }
               }, 'Data::FormValidator::Results' );

note isn't arrayref (correct)

#######################
Second load:

reality check: Sat Feb 28 11:29:03 EST 2004

$VAR1 = 'r';
$VAR2 = bless( { 
                 'profile' => {
                                'defaults' => {},
                                'dependencies' => {},
                                'dependency_groups' => {},
                                'constraints' => {},
                                'constraint_regexp_map' => {},
                                'required' => [ 
                                                'note'
                                              ],
                                'require_some' => {},
                                'field_filter_regexp_map' => {},
                                'field_filters' => {}
                              },
                 'validate_invalid' => [],
                 '__INPUT_DATA' => bless( { 
                                            '.parameters' => [ 
                                                               'note'
                                                             ],
                                            '.charset' => 'ISO-8859-1',
                                            '.r' => bless( do{\(my $o = 137736244)}, 'Apache' ),
                                            '.fieldnames' => {},
                                            'note' => [ 
                                                        '2003'
                                                      ],
                                            'escape' => 1
                                          }, 'CGI' ),
                 'unknown' => {
                                '.parameters' => 1,
                                '.r' => 1,
                                '.charset' => 1,
                                '.fieldnames' => 1,
                                'escape' => 1
                              },
                 'missing' => {},
                 'valid' => { 
                              'note' => $VAR2->{'__INPUT_DATA'}{'note'}
                            }
               }, 'Data::FormValidator::Results' );

note is arrayref (but shouldn't be)





-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: Help requested with CGI.pm/Data::FormValidator/modperl bug

Posted by Mark Stosberg <ma...@summersault.com>.
On 2004-02-29, Cees Hek <ce...@sitesuite.com.au> wrote:
> Hi Mark,
>
> What version of CGI.pm are you testing with?  There are some known 
> problems with using CGI.pm and mod_perl in older versions of CGI.pm. 
> Upgrade to the latest version of CGI.pm and my guess is your problem 
> will go away.

Cees,

I should have mentioned that: I'm using the newest version: 3.04.

	Mark

-- 
http://mark.stosberg.com/ 


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: Help requested with CGI.pm/Data::FormValidator/modperl bug

Posted by Cees Hek <ce...@sitesuite.com.au>.
Hi Mark,

What version of CGI.pm are you testing with?  There are some known 
problems with using CGI.pm and mod_perl in older versions of CGI.pm. 
Upgrade to the latest version of CGI.pm and my guess is your problem 
will go away.

Cheers,

Cees

Mark Stosberg wrote:
> Hello,
> 
> I maintain the popular Data::FormValidator module, and am just starting
> to use modperl myself. A couple of my users spotted a modperl-related
> bug in the module. I've read the "CGI porting" document about basic
> modperl traps, but I can't figure this out. 
> 
> I have a test script for the issue below. When run with "-X", it gives a
> different result on the second load. However, I'm not aware of global
> variables in use, and I'm not getting the "won't stay shared warning".    
> 
> Any pointers to help debug this will be appreciated by myself and the
> other DFV/modperl users.
> 
> BTW, the issue only happens with a CGI.pm object as input. Using a regular hashref 
> doesn't trigger it.
> 
> Thanks!
> 
> 	Mark
> 


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: Help requested with CGI.pm/Data::FormValidator/modperl bug

Posted by Mark Stosberg <ma...@summersault.com>.
On 2004-02-28, sagi <sa...@powweb.com> wrote:
> Have you tried using Apache::Request instead of CGI?. It also has a
> similar API to CGI, and if youre running mod_perl, you should be using
> Apache::Request :)
>
> Check out:
> http://search.cpan.org/~joesuf/libapreq-1.3/Request/Request.pm

I'm aware of Apache::Request. I understand it has better performance, I
believe it provides all the functionality I need. However, it's not a
good solution in this case for a few reasons:
 - My code needs to run unmodified under CGI and modperl for now.  
 - DFV currently has CGI-specific uploading code in it.
 - I want to support the other users of CGI/DFV/modperl.

It would be great of Apache::Request had a "Compatible" mode in which 
it provided the same API has CGI.pm does for the functions it offers. (For example, with file
uploading).  

I did try s/CGI/Apache::Request/ in my test script to see what
happened-- the error went away. Another user report trying the test
script with CGI.pm and not having the problem at all...  It looks like 
the problem could be as much with CGI.pm as it is with DFV. I'll try 
shopping my question on that list as well as see how I do.

Thanks for the response.

	Mark

-- 
http://mark.stosberg.com/ 


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


RE: Help requested with CGI.pm/Data::FormValidator/modperl bug

Posted by sagi <sa...@powweb.com>.
Have you tried using Apache::Request instead of CGI?. It also has a
similar API to CGI, and if youre running mod_perl, you should be using
Apache::Request :)

Check out:
http://search.cpan.org/~joesuf/libapreq-1.3/Request/Request.pm





-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Mark Stosberg
Sent: Saturday, February 28, 2004 8:41 AM
To: modperl@perl.apache.org
Subject: Help requested with CGI.pm/Data::FormValidator/modperl bug

Hello,

I maintain the popular Data::FormValidator module, and am just starting
to use modperl myself. A couple of my users spotted a modperl-related
bug in the module. I've read the "CGI porting" document about basic
modperl traps, but I can't figure this out. 

I have a test script for the issue below. When run with "-X", it gives a
different result on the second load. However, I'm not aware of global
variables in use, and I'm not getting the "won't stay shared warning".


Any pointers to help debug this will be appreciated by myself and the
other DFV/modperl users.

BTW, the issue only happens with a CGI.pm object as input. Using a
regular hashref 
doesn't trigger it.

Thanks!

	Mark

-- 
http://mark.stosberg.com/ 

###########################

#!/usr/bin/perl -w

use strict;
use CGI;
use Data::FormValidator;
use Data::Dumper;

my $r = Data::FormValidator->check(CGI->new('note=2003'),
{required=>[qw(note)]});

print "Content-type: text/html\n\n";
print "reality check: ".`date`;

print "<pre>". Dumper('r',$r).'</pre><p>';

if (ref  $r->valid('note') eq 'ARRAY' ) {
      print "note is arrayref (but shouldn't be)";
 }
 else {
     print "note isn't arrayref  (correct)";
 }

exit;

######################

First load:

reality check: Sat Feb 28 11:28:56 EST 2004

$VAR1 = 'r';
$VAR2 = bless( { 
                 'profile' => {
                                'defaults' => {},
                                'dependencies' => {},
                                'dependency_groups' => {},
                                'constraints' => {},
                                'constraint_regexp_map' => {},
                                'required' => [ 
                                                'note'
                                              ],
                                'require_some' => {},
                                'field_filter_regexp_map' => {},
                                'field_filters' => {}
                              },
                 'validate_invalid' => [],
                 '__INPUT_DATA' => bless( { 
                                            '.parameters' => [ 
                                                               'note'
                                                             ],
                                            '.charset' => 'ISO-8859-1',
                                            '.r' => bless( do{\(my $o =
137736244)}, 'Apache' ),
                                            '.fieldnames' => {},
                                            'note' => [ 
                                                        '2003'
                                                      ],
                                            'escape' => 1
                                          }, 'CGI' ),
                 'unknown' => {},
                 'missing' => {},
                 'valid' => { 
                              'note' => '2003'
                            }
               }, 'Data::FormValidator::Results' );

note isn't arrayref (correct)

#######################
Second load:

reality check: Sat Feb 28 11:29:03 EST 2004

$VAR1 = 'r';
$VAR2 = bless( { 
                 'profile' => {
                                'defaults' => {},
                                'dependencies' => {},
                                'dependency_groups' => {},
                                'constraints' => {},
                                'constraint_regexp_map' => {},
                                'required' => [ 
                                                'note'
                                              ],
                                'require_some' => {},
                                'field_filter_regexp_map' => {},
                                'field_filters' => {}
                              },
                 'validate_invalid' => [],
                 '__INPUT_DATA' => bless( { 
                                            '.parameters' => [ 
                                                               'note'
                                                             ],
                                            '.charset' => 'ISO-8859-1',
                                            '.r' => bless( do{\(my $o =
137736244)}, 'Apache' ),
                                            '.fieldnames' => {},
                                            'note' => [ 
                                                        '2003'
                                                      ],
                                            'escape' => 1
                                          }, 'CGI' ),
                 'unknown' => {
                                '.parameters' => 1,
                                '.r' => 1,
                                '.charset' => 1,
                                '.fieldnames' => 1,
                                'escape' => 1
                              },
                 'missing' => {},
                 'valid' => { 
                              'note' => $VAR2->{'__INPUT_DATA'}{'note'}
                            }
               }, 'Data::FormValidator::Results' );

note is arrayref (but shouldn't be)





-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html