[pLog-svn] r6451 - plog/trunk/class/database
Jon Daley
plogworld at jon.limedaley.com
Mon May 26 10:31:25 EDT 2008
I got the idea from other php software. I would bet about 20% of
the forums questions are due to the server not being setup to show php
errors for security reasons or whatever, and the users don't have access
to the error logs. If we trap the errors, then the user can actually see
them, rather than just seeing a white page.
This technique can also avoid errors where we don't want to show
them, like extra whitespace in the locale files, etc. we can just throw it
away, or maybe write the message into lifetype.log, and avoid another set
of questions on the forums (and avoid the crash messages).
Similarly, I'll want to add a bit of code to the wizard if they
try to run lifetype under php4, rather than seeing the horrible error that
no one will understand what it means, and figure LifeType is broken,
rather than switching to php5.
On Mon, 26 May 2008, Mark Wu wrote:
> Hi Jon:
>
> I try this n in my local development machine, I get
>
> " Header already send" error message everywhere.
>
> So, I revert it first to get the further developemet can go on.
>
> BTW, I think we just need to show the error messages from DB here, why you
> want to capture the whole error?? Any ideas?
>
> Mark
>
>> -----Original Message-----
>> From: plog-svn-bounces at devel.lifetype.net
>> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of
>> jondaley at devel.lifetype.net
>> Sent: Friday, May 09, 2008 10:38 PM
>> To: plog-svn at devel.lifetype.net
>> Subject: [pLog-svn] r6451 - plog/trunk/class/database
>>
>> Author: jondaley
>> Date: 2008-05-09 10:38:01 -0400 (Fri, 09 May 2008) New Revision: 6451
>>
>> Modified:
>> plog/trunk/class/database/ltdb.class.php
>> Log:
>> use output buffering to catch php library errors (we can use
>> this method to catch lots of issues, like plugins/locales/etc
>> that have extra spaces/newlines/etc in them). auto retry for
>> hosts that don't allow non-persistent connections. remove
>> die() since we have exceptions
>>
>> Modified: plog/trunk/class/database/ltdb.class.php
>> ===================================================================
>> --- plog/trunk/class/database/ltdb.class.php 2008-05-09
>> 14:12:33 UTC (rev 6450)
>> +++ plog/trunk/class/database/ltdb.class.php 2008-05-09
>> 14:38:01 UTC (rev 6451)
>> @@ -76,20 +76,26 @@
>> $dbcharset = $fileConfig->getValue(
>> "db_character_set", DEFAULT_DATABASE_CHARSET );
>> $dbpersistent = $fileConfig->getValue(
>> "db_persistent" );
>> if($dbpersistent == true) {
>> + ob_start();
>> if( !$db->PConnect( $host, $username,
>> $password, $dbname, $dbcharset )) {
>> - $message = "Fatal error: could not
>> connect to the database!".
>> - " Error: ".$db->ErrorMsg();
>> - throw( new Exception( $message ));
>> - die();
>> - }
>> + // some hosts don't allow
>> persistent connections, just retry
>> + // with a regular connect, and
>> avoid an error message
>> + if( !$db->Connect( $host, $username,
>> $password, $dbname, $dbcharset )) {
>> + $message = "Fatal error: could
>> not connect to the database!".
>> + " Error:
>> ".$db->ErrorMsg().ob_get_clean();
>> + throw( new Exception( $message ));
>> + }
>> + }
>> + ob_end_flush();
>> }
>> else {
>> + ob_start();
>> if( !$db->Connect( $host, $username,
>> $password, $dbname, $dbcharset )) {
>> $message = "Fatal error: could not
>> connect to the database!".
>> - " Error: ".$db->ErrorMsg();
>> + " Error:
>> ".$db->ErrorMsg().ob_get_clean();
>> throw( new Exception( $message ));
>> - die();
>> }
>> + ob_end_flush();
>> }
>>
>> // pass the options to the
>> driver, if any
>>
>> _______________________________________________
>> pLog-svn mailing list
>> pLog-svn at devel.lifetype.net
>> http://limedaley.com/mailman/listinfo/plog-svn
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn
>
--
Jon Daley
http://jon.limedaley.com/
There are really only two bases: 2 and e.
-- Michael Brian McElroy
More information about the pLog-svn
mailing list