From 361a74963f5a34c025a143be4f9d24c9008f358c Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 11 Oct 2022 08:26:36 +0100 Subject: [PATCH] Bug 31729: Add missing brace (and tidy) This adds a missing closing bracket and runs perltidy over the .psgi scripts. --- app.psgi | 13 ++++---- debian/templates/plack.psgi | 60 ++++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/app.psgi b/app.psgi index 7c6b3f6232..d2ca4a33a2 100644 --- a/app.psgi +++ b/app.psgi @@ -30,13 +30,13 @@ sub psgi_app { return $server->to_psgi_app; } -my $opac = psgi_app('bin/opac'); +my $opac = psgi_app('bin/opac'); my $intranet = psgi_app('bin/intranet'); -my $opac_port = $ENV{KOHA_OPAC_PORT} || 5001; +my $opac_port = $ENV{KOHA_OPAC_PORT} || 5001; my $intranet_port = $ENV{KOHA_INTRANET_PORT} || 5000; -my $port2app = { - $opac_port => $opac, +my $port2app = { + $opac_port => $opac, $intranet_port => $intranet, }; @@ -48,7 +48,8 @@ builder { my $app = shift; sub { my $env = shift; - $env->{'koha.app'} = $port2app->{$env->{SERVER_PORT}} || $intranet; + $env->{'koha.app'} = + $port2app->{ $env->{SERVER_PORT} } || $intranet; return $app->($env); } }; @@ -58,7 +59,7 @@ builder { enable '+Koha::Middleware::RealIP'; # bz 31729, enable filesystem reload for dev plack - enable "Refresh", cooldown => 3 if ($ENV{DEV_INSTALL} ; + enable "Refresh", cooldown => 3 if ( $ENV{DEV_INSTALL} ); sub { my $env = shift; diff --git a/debian/templates/plack.psgi b/debian/templates/plack.psgi index d1401a17db..aa1735b5c6 100644 --- a/debian/templates/plack.psgi +++ b/debian/templates/plack.psgi @@ -38,12 +38,12 @@ use Koha::DateUtils; use Koha::Logger; use Log::Log4perl; -use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise +use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise { no warnings 'redefine'; my $old_new = \&CGI::new; *CGI::new = sub { - my $q = $old_new->( @_ ); + my $q = $old_new->(@_); $CGI::PARAM_UTF8 = 1; Koha::Caches->flush_L1_caches(); Koha::Cache::Memory::Lite->flush(); @@ -51,16 +51,15 @@ use CGI qw(-utf8 ); # we will loose -utf8 under plack, otherwise }; } -my $home = $ENV{KOHA_HOME}; +my $home = $ENV{KOHA_HOME}; my $intranet = Plack::App::CGIBin->new( - root => $ENV{DEV_INSTALL}? $home: "$home/intranet/cgi-bin" -)->to_app; + root => $ENV{DEV_INSTALL} ? $home : "$home/intranet/cgi-bin" )->to_app; my $opac = Plack::App::CGIBin->new( - root => $ENV{DEV_INSTALL}? "$home/opac": "$home/opac/cgi-bin/opac" -)->to_app; + root => $ENV{DEV_INSTALL} ? "$home/opac" : "$home/opac/cgi-bin/opac" ) + ->to_app; -my $apiv1 = builder { +my $apiv1 = builder { my $server = Mojo::Server::PSGI->new; $server->load_app("$home/api/v1/app.pl"); $server->to_psgi_app; @@ -73,52 +72,57 @@ builder { enable "Plack::Middleware::Static"; # bz 31729, enable filesystem reload for dev plack - enable "Refresh", cooldown => 3 if ($ENV{DEV_INSTALL} ; + enable "Refresh", cooldown => 3 + if ( $ENV{DEV_INSTALL} ); # + is required so Plack doesn't try to prefix Plack::Middleware:: enable "+Koha::Middleware::SetEnv"; enable "+Koha::Middleware::RealIP"; - mount '/opac' => builder { + mount '/opac' => builder { + #NOTE: it is important that these are relative links enable 'ErrorDocument', - 400 => 'errors/400.pl', - 401 => 'errors/401.pl', - 402 => 'errors/402.pl', - 403 => 'errors/403.pl', - 404 => 'errors/404.pl', - 500 => 'errors/500.pl', - subrequest => 1; + 400 => 'errors/400.pl', + 401 => 'errors/401.pl', + 402 => 'errors/402.pl', + 403 => 'errors/403.pl', + 404 => 'errors/404.pl', + 500 => 'errors/500.pl', + subrequest => 1; + #NOTE: Without this middleware to catch fatal errors, ErrorDocument won't be able to render a 500 document #NOTE: This middleware must be closer to the PSGI app than ErrorDocument enable "HTTPExceptions"; - if ( Log::Log4perl->get_logger('plack-opac')->has_appenders ){ + if ( Log::Log4perl->get_logger('plack-opac')->has_appenders ) { enable 'Log4perl', category => 'plack-opac'; enable 'LogWarn'; } $opac; }; - mount '/intranet' => builder { + mount '/intranet' => builder { + #NOTE: it is important that these are relative links enable 'ErrorDocument', - 400 => 'errors/400.pl', - 401 => 'errors/401.pl', - 402 => 'errors/402.pl', - 403 => 'errors/403.pl', - 404 => 'errors/404.pl', - 500 => 'errors/500.pl', - subrequest => 1; + 400 => 'errors/400.pl', + 401 => 'errors/401.pl', + 402 => 'errors/402.pl', + 403 => 'errors/403.pl', + 404 => 'errors/404.pl', + 500 => 'errors/500.pl', + subrequest => 1; + #NOTE: Without this middleware to catch fatal errors, ErrorDocument won't be able to render a 500 document #NOTE: This middleware must be closer to the PSGI app than ErrorDocument enable "HTTPExceptions"; - if ( Log::Log4perl->get_logger('plack-intranet')->has_appenders ){ + if ( Log::Log4perl->get_logger('plack-intranet')->has_appenders ) { enable 'Log4perl', category => 'plack-intranet'; enable 'LogWarn'; } $intranet; }; mount '/api/v1/app.pl' => builder { - if ( Log::Log4perl->get_logger('plack-api')->has_appenders ){ + if ( Log::Log4perl->get_logger('plack-api')->has_appenders ) { enable 'Log4perl', category => 'plack-api'; enable 'LogWarn'; } -- 2.20.1