- 2010-08-16: France.FR is back online with OSInet and Typhon
- 2010-06-15: the new http://www.franceculture.com/, which OSInet helped reach its performance goals, is now online
- 2010-06-13: the OSInet Features Server is live
- 2009-11-29: mongodb_watchdog module created by dereine, ported to D7 by me in about half an hour, and migrated in a larger MongoDB project by damz before the hour ended. Wow...
- 2009-07-13: 100% unit test coverage on Taxonews for both D6 and D7 versions
- 2009-02-03: the new Drupal-based site for the golden jubilee of the french "Ministère de la Culture", which OSInet helped build, is now online
- 2009-01-22: new API site for CCK à la api.drupal.org
Debug vanilla
Submitted by fgm on Fri, 2009-12-11 13:14
Most of the time, when working on some piece of code, I'll resort to the configured debugger in my current Zend Studio configuration. And you probably do too :-)
However, I often have to access debug-type information on live sites where installing a debugger is out of the question, and I find myself often resorting to parameter dumps like the following:
<?php
// lazy version for simple cases
function foo_bar($x, $y, $z) {
dsm(func_get_args());
// [...]
// less lazy version for more hairy cases
function foo_baz($x, $y, $z) {
dsm(array('in foo_baz, x' => $x, 'y' => $y, 'z' => $z));
// ...
?>You've probably being using it too and, of course, after the first few dozen times, it becomes a bit used. So here's a tiny snippet that makes such dumps simpler to type and use :
<?php
function foo_quux($x, $y, $z) {
dsm(func_get_args_hash());
// [...]
/**
* Provide a better func_get_args()
*
* @return array
* Hash of parameters, keyed by parameter name
*/
function func_get_args_hash() {
$stack = debug_backtrace();
$stack = $stack[1];
$rf = new ReflectionFunction($stack['function']);
$params = $rf->getParameters();
$ret = array();
foreach ($params as $index => $param) {
$ret[$param->name] = $stack['args'][$index];
}
return $ret;
}
?>






Knowing next to nothing about
Knowing next to nothing about reflection, I can't see what makes this better than vanila dsm() or dpm(). What does the output look like?
Parameter names and default values
When using
dsm(func_get_args_hash())instead ofdsm(func_get_args()), you get:dsm(func_get_args()).When you're bug-hunting, it's often useful (to me at least) to know which parameter is being represented by a value in the args dump, and which values all the parameters have, default or explicit.
Sample use on
_locale_import_one_string_db()below.