Bug 7895: Test for PSGI-related env to report in about.pl
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 21 Oct 2015 01:50:47 +0000 (22:50 -0300)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 10 Nov 2015 18:18:28 +0000 (15:18 -0300)
This patch introduces a test for psgi/plack in %ENV and uses that data
to report in the about page.

To test:
- On current master (without Plack), go to about.pl
- Notice no mention of Plack
- Apply the patch
- Reload the about page
=> SUCCESS: No change
- Enable plack, and access the about page through Plack
=> SUCCESS: There is a PSGI label, showing that you are running Plack
- Sign off :-D

Regards

PS: I haven't tested the mod_perl scenario, I just grabbed the MOD_PERL env var
from the docs.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

about.pl
koha-tmpl/intranet-tmpl/prog/en/modules/about.tt

index 4c27366..01e941c 100755 (executable)
--- a/about.pl
+++ b/about.pl
 # You should have received a copy of the GNU General Public License
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
-use warnings;
+use Modern::Perl;
 
 use CGI qw ( -utf8 );
+use List::MoreUtils qw/ any /;
 use LWP::Simple;
 use XML::Simple;
 use Config;
@@ -65,6 +65,16 @@ $apacheVersion    = `httpd2 -v 2> /dev/null` unless $apacheVersion;
 $apacheVersion    = `httpd -v 2> /dev/null` unless $apacheVersion;
 my $zebraVersion = `zebraidx -V`;
 
+# Check running PSGI env
+if ( any { /(^psgi\.|^plack\.)/i } keys %ENV ) {
+    $template->param(
+        is_psgi => 1,
+        psgi_server => ($ENV{ PLACK_ENV }) ? "Plack ($ENV{PLACK_ENV})" :
+                       ($ENV{ MOD_PERL })  ? "mod_perl ($ENV{MOD_PERL})" :
+                                             'Unknown'
+    );
+}
+
 # Additional system information for warnings
 my $prefAutoCreateAuthorities = C4::Context->preference('AutoCreateAuthorities');
 my $prefBiblioAddsAuthorities = C4::Context->preference('BiblioAddsAuthorities');
index bcf4b5c..079a340 100644 (file)
@@ -48,6 +48,9 @@
             </td></tr>
             <tr><th scope="row">MySQL version: </th><td>[% mysqlVersion |html %]</td></tr>
             <tr><th scope="row">Apache version: </th><td>[% apacheVersion |html %]</td></tr>
+          [% IF (is_psgi) %]
+            <tr><th scope="row">PSGI: </th><td>[% psgi_server |html %]</td></tr>
+          [% END %]
             <tr><th scope="row">Zebra version: </th><td>[% zebraVersion |html %]</td></tr>
             [% IF (errZebraConnection == 10000) %]
             <tr><th scope="row"><b>Error</b> </th><td>Zebra server seems not to be available. Is it started?</td></tr>