The dpm() function and consorts currently do not return anything. To ease debugging it would be helpful to simply return the original input value, which would allow debugging inside code statements where currently copy-pasting code is required. E.g. the following would become possible:

// Debugging inside if() statements:
if (dpm(function_result_to_check()) || dpm(another_function())) { …

// Debugging return values without having to copy-paste first:
return dpq(db_select(…)->fields(…)->execute());
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

smk-ka’s picture

Status: Active » Needs review
FileSize
2.02 KB

Like this.

salvis’s picture

Great idea, this has bothered me, too.

However, have you tried your example?

+++ b/devel.module
@@ -1576,34 +1578,50 @@ function dpq($query, $return = FALSE, $name = NULL) {
+      return dpm($sql, $name);

This returns the SQL string rather than the $query object.

I'd suggest doing it this way.

salvis’s picture

Title: Make dpm() and friends chainable (sort of) » Make dpm() and friends transparent
Status: Needs review » Fixed

Well, I want to have this!

Committed #2 to D8/D7. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.