koha-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-devel] Re: [Koha] premature end of script headers


From: Rick Welykochy
Subject: [Koha-devel] Re: [Koha] premature end of script headers
Date: Fri, 19 Jan 2007 13:10:29 +1100
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.13) Gecko/20060414

Robert Lyon wrote:

Is that error from the koha error logs?

The apache error log

if so try looking at the apache error log too - it might give some idea
but to me it looks like the acqui-home.pl might have the wrong file permissions on it and can't run

No, the script *used to* run fine.

I found the cause of the problem by running the script in the
shell. I could no longer connect to the MySQL database server
since I had changed the name of the database user.

Now the problem is fixed.
This raises a couple of issues:

1. Why is the admin login username (to the Intranet) the same as
   the database username? The two should be separate, esp. for
   security reasons.

2. When the script that fails runs in the shell, I can clearly
   see the error:

   perl ./intranet/cgi-bin/mainpage.pl
   DBI connect('eesv2pre5:localhost','kohaadmin',...) failed: Access denied for 
user 'kohaadmin'@'%'
   to database'Koha' at /usr/local/koha/intranet/modules/C4/Context.pm line 411
   Can't call method "prepare" on an undefined value at 
/usr/local/koha/intranet/modules/C4/Koha.pm line 388.

   Surely the same error message should be sent to the Apache log, rather
   than "premature end of script headers". I think the problem lies in the way
   Perl is being used. If Koha used mod_perl instead, this problem would not 
occur,
   since mod_perl can do things like ensure you have a valid database connection
   during Apache initialisation -- if there is a problem, mod_perl can be
   configured to abort the Apache startup. This would be a Good Thing (tm).
   Another Good Thing is mod_perl will run the scripts 100 x faster!

A way to avoid the cryptic "Premature end of script headers" in scripts
is to use the exception handling facility of Perl.

For programmers only: each script is in an eval { } block and any
errors caught, the HTTP headers output and then the error raised
properly with Apache. I've been using this approach for years in
LAMP apps -- works a treat, and no moer tears ;)

My concern the the inordinate waste of hundreds of Koha users/installers
time with the cryptic error message which can easily be ameliorated
by a few programming tweaks. (This error is constantly being raised
on the Koha user's mailing list)

We can further discuss this on the koha-devel list if you wish.

Advice to Koha users/installers: if you see the cryptic error message
run the same script in the shell:

PERL5LIB=/usr/local/koha/intranet/modules perl {FULL_PATH_TO_SCRIPT_HERE}


cheers
rickw




Rick Welykochy wrote:

I am running Koha/2.2.7 on LAMP.

One of the scripts is causing a 500 error. The error log does not show
any perl error report, rather just the following:

[Fri Jan 19 00:14:18 2007] [error] [client 192.168.0.3] Premature end of script headers: acqui-home.pl

Any idea what causes this?




--
_________________________________
Rick Welykochy || Praxis Services

The 7 R's of Windows support: retry, restart, reboot, reconfigure,
reinstall, reformat and finally, replace with Linux.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]