For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > April 2004 > Re: [PEAR] Re: MDB2 beta1 problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] Re: MDB2 beta1 problem
Joshua Eichorn

2004-04-22, 5:34 pm

Oh must be the custom error handler i wrote is forgetting to ignore
silenced errors. Wouldn't it be better to do a is_readable check before
doing the include.
-josh
Lukas Smith wrote:

> Joshua Eichorn wrote:
>
>
>
> hmm since there is no way to check if a file is includeable MDB2 first
> tries to include the module from the MDB2 dir and if its missing from
> the drivers dir. So the include error is actually silenced and it
> should try to include MDB2/Driver/Datatype/[rdbms].php ...
>
> regards,
> Lukas Smith
> smith@backendmedia.com
> _______________________________
> BackendMedia
> www.backendmedia.com
> berlin@backendmedia.com
>
> Linn Zwoch Smith GbR
> Pariser Str. 44
> D-10707 Berlin
>
> Tel +49 30 83 22 50 00
> Fax +49 30 83 22 50 07
>

Lukas Smith

2004-04-22, 5:34 pm

Joshua Eichorn wrote:

> Oh must be the custom error handler i wrote is forgetting to ignore
> silenced errors. Wouldn't it be better to do a is_readable check before
> doing the include.


unforunately that doesnt work as internals@ doesnt think a method to
detect if a file is includeable is useful. is_readable() doesnt use the
include_path

regards,
Lukas Smith
smith@backendmedia.com
_______________________________
BackendMedia
www.backendmedia.com
berlin@backendmedia.com

Linn Zwoch Smith GbR
Pariser Str. 44
D-10707 Berlin

Tel +49 30 83 22 50 00
Fax +49 30 83 22 50 07
Hodicska Gergely

2004-04-23, 7:35 am

Hi!

> unforunately that doesnt work as internals@ doesnt think a method to
> detect if a file is includeable is useful. is_readable() doesnt use the
> include_path


Maybe you can use something like this:
ob_start();
include($file);
$error = ob_get_contents();
ob_end_clean();
if ($error != '') {
// eroro handling - trigger_error();
}

Felho
Lukas Smith

2004-04-23, 7:35 am

Hodicska Gergely wrote:

> Hi!
>
>
>
> Maybe you can use something like this:
> ob_start();
> include($file);
> $error = ob_get_contents();
> ob_end_clean();
> if ($error != '') {
> // eroro handling - trigger_error();
> }


yeah maybe that is a solution .. but actually this is still probably
going to call error callbacks. so the only solution would be to write my
own is_includeable in php .. nasty nasty

regards,
Lukas Smith
smith@backendmedia.com
_______________________________
BackendMedia
www.backendmedia.com
berlin@backendmedia.com

Linn Zwoch Smith GbR
Pariser Str. 44
D-10707 Berlin

Tel +49 30 83 22 50 00
Fax +49 30 83 22 50 07
Hodicska Gergely

2004-04-23, 7:35 am

Hi!

> yeah maybe that is a solution .. but actually this is still probably
> going to call error callbacks.

What do you mean?

Felho
Lukas Smith

2004-04-23, 7:35 am

Hodicska Gergely wrote:
> Hi!
>
>
> What do you mean?


even if I buffer the error message, it will still trigger a custom error
handler which is the problem Joshua is having.

regards,
Lukas Smith
smith@backendmedia.com
_______________________________
BackendMedia
www.backendmedia.com
berlin@backendmedia.com

Linn Zwoch Smith GbR
Pariser Str. 44
D-10707 Berlin

Tel +49 30 83 22 50 00
Fax +49 30 83 22 50 07
Hodicska Gergely

2004-04-23, 7:35 am

Hi!

> even if I buffer the error message, it will still trigger a custom error
> handler which is the problem Joshua is having.


Ok, and what about this:
var_dump(@include('existing.php')); // int-1
var_dump(@include('notExisting.php')); // bool-false

Felho
Lukas Smith

2004-04-23, 7:35 am

Hodicska Gergely wrote:
> Hi!
>
>
>
> Ok, and what about this:
> var_dump(@include('existing.php')); // int-1
> var_dump(@include('notExisting.php')); // bool-false


this is what I do :-)

but appearently Joshuas error call back gets triggered even for silenced
errors. I dont have much experience with custom error handlers though.

regards,
Lukas Smith
smith@backendmedia.com
_______________________________
BackendMedia
www.backendmedia.com
berlin@backendmedia.com

Linn Zwoch Smith GbR
Pariser Str. 44
D-10707 Berlin

Tel +49 30 83 22 50 00
Fax +49 30 83 22 50 07
Hodicska Gergely

2004-04-23, 8:33 am

Hi!

> this is what I do :-)
>
> but appearently Joshuas error call back gets triggered even for silenced
> errors. I dont have much experience with custom error handlers though.


The problem is (I think) with Joshua's error handler, that he don't call
before echoing the error message the error_reporting function.

if (error_reporting()) {
echo $errMsg;
} else {
// There was a silenced error
}

Felho
Joshua Eichorn

2004-04-23, 1:37 pm

Hodicska Gergely wrote:

> Hi!
>
>
>
> The problem is (I think) with Joshua's error handler, that he don't call
> before echoing the error message the error_reporting function.
>
> if (error_reporting()) {
> echo $errMsg;
> } else {
> // There was a silenced error
> }
>
> Felho
>

Thats pretty much it, i'm actually overriding my more complex one since
im running this code into a script and fancy html output doesn't look to
hot on my term and i forgot to add that check in.

Of course it would still be nicer if php had a method so you could check
if including was possible instead of silencing errors since even a
silenced error goes into the error reporting code and is slower.
-josh
Greg Beaver

2004-04-27, 1:21 am

Lukas Smith wrote:

> yeah maybe that is a solution .. but actually this is still probably
> going to call error callbacks. so the only solution would be to write my
> own is_includeable in php .. nasty nasty


I wrote this code for phpDocumentor, it's in
PhpDocumentor/phpDocumentor/Io.php. 6 or 7 lines as Io::isIncludeable.
I know you won't like the explode and loop of include_path, but the
good news is that most include_paths are only 2 or three components. I
suspect this won't be much slower, if at all, than the calling of custom
error handlers, but haven't done benchmarking.

Greg
Lukas Smith

2004-04-27, 5:09 am

Greg Beaver wrote:
> Lukas Smith wrote:
>
>
>
> I wrote this code for phpDocumentor, it's in
> PhpDocumentor/phpDocumentor/Io.php. 6 or 7 lines as Io::isIncludeable.
> I know you won't like the explode and loop of include_path, but the
> good news is that most include_paths are only 2 or three components. I
> suspect this won't be much slower, if at all, than the calling of custom
> error handlers, but haven't done benchmarking.


yeah I should probably do this, as silencing errors in this way simply
is ugly to me.

regards,
Lukas Smith
smith@backendmedia.com
_______________________________
BackendMedia
www.backendmedia.com
berlin@backendmedia.com

Linn Zwoch Smith GbR
Pariser Str. 44
D-10707 Berlin

Tel +49 30 83 22 50 00
Fax +49 30 83 22 50 07
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com