Bug 24719: Remove use of CGI object in C4::Context::set_remote_address()

This patch replaces the CGI "http" object method with its equivalent
class method, which doesn't require object instantiation and thus skips
global initialization and premature handling of the incoming HTTP request.

Test plan:
0. Disable Plack if it is enabled
1. Set koha_trusted_proxies in koha-conf.xml to 1.1.1.1
2. Clear Memcached
3. Try to upload MARCXML file to /cgi-bin/koha/tools/stage-marc-import.pl
4. Note that form below "Upload progress" never appears and errors show
in browser console
5. Apply the patch
6. Try to upload MARCXML file to /cgi-bin/koha/tools/stage-marc-import.pl
7. Note that form appears below "Upload progress"

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
David Cook 2020-02-27 00:28:48 +00:00 committed by Martin Renvoize
parent 8b003f4b73
commit 0fcbec7507
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F

View file

@ -1063,8 +1063,7 @@ variable to be set correctly.
sub set_remote_address {
if ( C4::Context->config('koha_trusted_proxies') ) {
require CGI;
my $cgi = CGI->new;
my $header = $cgi->http('HTTP_X_FORWARDED_FOR');
my $header = CGI->http('HTTP_X_FORWARDED_FOR');
if ($header) {
require Koha::Middleware::RealIP;