Edit report at
http://pear.php.net/bugs/bug.php?id=18838&edit=1ID: 18838
Updated by: daniel.oconnor@gmail.com
Reported By: gacek at intertele dot pl
Summary: Syntax error in Container/shm.php, bad coding in
Cache.php
Status: Open
Type: Bug
Package: Cache
Package Version: 1.5.7
PHP Version: Irrelevant
-Assigned To:
+Assigned To: ivonascimento
Roadmap Versions:
New Comment:
-Assigned To:
+Assigned To: ivonascimento
Previous Comments:
------------------------------------------------------------------------
[2011-09-16 14:46:47] gacek
I't depends, what you consider "the better".
In the case of syntax error (not so uncommon in PEAR::Cache codebase as
you can see), my site was generating HTTP 500
without any clue, any error message. Just blank page. No error message,
no error entry in logs.
It took me an hour to nail it down, checking file by file, include by
include, dozens of that.
Just did the simple upgrade of PEAR package.
Unacceptable in commercial / enterprise environment.
For me, as the developer and user of PEAR::Cache it's even better
feedback if I see, what file it did try to include and why it failed
than to get 'nice Cache_Error'.
You seem to misunderstand what "good feedback" means for the developer.
------------------------------------------------------------------------
[2011-09-16 13:57:24] ivonascimento
gacek,
I explain Why I use '@' to hidden the include messages.
@include_once $container_classfile;
if (class_exists($container_class)) {
$this->container = new
$container_class($container_options);
} else {
$this->container = new Cache_Error(
"The Container requested {$container} is not supported"
);
}
If the parameter $container in construct is a string, the user can passa
a value with a invalid container type/name.
If its happen the include will fail.
it this fail, the better way to response is with a Cache_Error and not a
simply fatal error.
Its the motivation to use @. Not to hidden the error but do a better
feedback to developer when this error happen.
So, with this, the error are catchable right now and its a better
scenario then a fatal error.
------------------------------------------------------------------------
[2011-09-16 13:08:01] doconnor
I've just pulled the release due to the syntax error.
------------------------------------------------------------------------
[2011-09-16 11:35:14] gacek
Description:
------------
new "stable" (sic!) version 1.5.7 contains syntax error in shm.php:
PHP Parse error: syntax error, unexpected T_IF in
/www/virtual/testy/libs/pear/Cache/Container/shm.php on line 124
This new version of class Cache constructor behaves badly, masking that
syntax error by usage of @include_once ...
The purpose of error message is to be displayed or logged, and not to be
hidden!
If you want to hide errors from users in your site, use
ini_set('display_errors', false), but reusable code like PEAR,
PEAR::Cache, etc. should not hide them!
------------------------------------------------------------------------