Symptoms and impact
When trying to use the
GenPDF extension with the 5.0.1 I've received following error after running genpdf script:
Undefined subroutine CGI::remoteAddress
at /srv/www/twiki/lib/TWiki/LoginManager/Session.pm line 45
at /usr/lib/perl5/5.12.1/CGI.pm line 893
CGI::_compile called at /usr/lib/perl5/5.12.1/CGI.pm line 857
CGI::AUTOLOAD('CGI=HASH(0x8cab50)') called at /srv/www/twiki/lib/TWiki/LoginManager/Session.pm line 45
TWiki::LoginManager::Session::load('TWiki::LoginManager::Session', undef, 'CGI=HASH(0x8cab50)', 'HASH(0x14d6e70)') called at /usr/lib/perl5/vendor_perl/5.12.1/CGI/Session.pm line 64
CGI::Session::new('TWiki::LoginManager::Session', undef, 'CGI=HASH(0x8cab50)', 'HASH(0x14d6e70)') called at /srv/www/twiki/lib/TWiki/LoginManager.pm line 321
TWiki::LoginManager::loadSession('TWiki::LoginManager::TemplateLogin=HASH(0x142a940)', undef) called at /srv/www/twiki/lib/TWiki/Users.pm line 115
TWiki::Users::new('TWiki::Users', 'TWiki=HASH(0x120c168)') called at /srv/www/twiki/lib/TWiki.pm line 1552
TWiki::new('TWiki', undef, 'CGI=HASH(0x8cab50)') called at /srv/www/twiki/lib/TWiki.pm line 3342
TWiki::initialize('/TWiki/GenPDFAddOn', undef, undef, 'http://localhost/twiki/bin/genpdf', 'CGI=HASH(0x8cab50)') called at /srv/www/twiki/lib/TWiki/Contrib/GenPDF.pm line 595
TWiki::Contrib::GenPDF::viewPDF() called at /srv/www/twiki/bin/genpdf line 43
This effectively made the
GenPDF unusable with 5.0.1 (probably 5.0.0 has the same issue as noted in the dev discussion for the plugin).
Details
LoginManager::Session has
load method that looks like this in 5.0.1:
42 sub load {
43 my $this = shift;
44 # local %ENV; # TWikibug:Item6583 - commented out
45 $ENV{REMOTE_ADDR} = @_ == 1 ? $_[0]->remoteAddress : $_[1]->remoteAddress;
46 $this->SUPER::load(@_);
47 }
There is a bug in line 45, because the CGI object that is passed as the argument does not have method called remoteAddress - the relevant method is called remote_addr. Seems like someone misspelled the method name.
Fix
I've changed line 45 to:
$ENV{REMOTE_ADDR} = @_ == 1 ? $_[0]->remote_addr : $_[1]->remote_addr;
GenPDF is working again in 5.0.1 after the fix. I don't see any potential side effects.