Req #60897 [NEW]: Advocating trigger_error instead of exit/die()
| From: | luiheidsgoeroe at hotmail dot com | Date: | Thu, 26 Jan 2012 23:36:40 +0000 |
| Subject: | Req #60897 [NEW]: Advocating trigger_error instead of exit/die() | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-7871@lists.php.net to get a copy of this message | ||
From:
Operating system: Irrelevant
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Feature/Change Request
Bug description:Advocating trigger_error instead of exit/die()
Description:
------------
Although examples in the documentation are of course only meant as
illustrations, we all know that starting developers copy/paste huge chunks
of code and then fiddle with the details to get things working. Usually,
this turns out alright, but the use of exit(<error message>) and/or
die(<error message>) on any error (mysql_connect comes to mind) is
widespread in the documentation. This is terrible to debug later, does not
leave a message in the error log, and in 3rd party included libraries it is
just plain evil.
I'd like to advocate:
1) Adding a note to exit()/die() that trigger_error('some message',
E_USER_ERROR) would be preferable in production (easily done if people
agree with this).
2) Modifying most if not all examples in the documentation that use die()
to that trigger_error() (a lot of work).
It is of course debatable whether this should happen, as trigger_error()
with display_errors on differs with die() in also showing path &
linenumber, which is not information visitors should normally get, but then
again, neither should display_errors be on. Also an issue could be it
clutters the examples somewhat with non-relevant statements, but it is not
terribly more verbose then the die()'s that are there now.
In my opinion, it would advocate good practices in coding and relieve a lot
of irritation and obscurity in debugging code from new coders and
monitoring issues.
Should this be accepted as indeed the way to go, I would be perfectly
willing to comb through the documentation to alter die()/exit() statements
to this format and submit a patch, but - as it will take a while - not
until there is a definite decision that this is what desirable, otherwise
I'd be wasting my time.
--
Edit bug report at https://bugs.php.net/bug.php?id=60897&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60897&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60897&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60897&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=60897&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60897&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=60897&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=60897&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=60897&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=60897&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=60897&r=support
Expected behavior: https://bugs.php.net/fix.php?id=60897&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=60897&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=60897&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=60897&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60897&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60897&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=60897&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=60897&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=60897&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=60897&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=60897&r=mysqlcfg