From 3fbadc9b8ac834d042d4d55214accfb48947ab13 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 27 Feb 2020 00:28:48 +0000 Subject: [PATCH] Bug 24719: [Alternate PATCH] 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 --- C4/Context.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index 36d68b195c..7b10f8f1d0 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -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; -- 2.11.0