This has really been driving me nuts. So itch, meet scratch.

In order to call debug(array()) I need to type debug(array(), '', TRUE). The TRUE indicates that print_r should be used instead of var_export. Fair enough, but that empty string is necessary in order to get to the third argument, which is FALSE by default.

So I propose that if the second argument is a Boolean, just deal with it and use print_r without a label.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jessebeach’s picture

Issue summary: View changes
tim.plunkett’s picture

+++ b/core/includes/common.inc
@@ -5033,6 +5033,13 @@ function _drupal_flush_css_js() {
 function debug($data, $label = NULL, $print_r = FALSE) {

Why not just switch the param orders? I've never used the label, I use the print_r flag a lot. But i think this is almost more confusing.

Berdir’s picture

I don't think we should mis-use an argument for something else.

I use the label quite a lot, helps when to identify things when you have a lot of debug statements.

jessebeach’s picture

Let's set $print_r to be true by default then.

Status: Needs review » Needs work

The last submitted patch, 4: debug-without-a-label-2174507-4.patch, failed testing.

tim.plunkett’s picture

Title: Allow a user to call debug() on an array with print_r without a label » Make debug() use print_r() by default
Status: Needs work » Needs review
Issue tags: -OMGWTFBBQ +Drupal wtf
FileSize
1.4 KB

Fine by me.

alansaviolobo’s picture

reroll

Status: Needs review » Needs work

The last submitted patch, 7: make_debug_use-2174507-7.patch, failed testing.

alansaviolobo’s picture

Status: Needs work » Needs review
FileSize
1.34 KB

ended up exporting a reversed patch.

Status: Needs review » Needs work

The last submitted patch, 9: make_debug_use-2174507-9.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 9: make_debug_use-2174507-9.patch, failed testing.

Status: Needs work » Needs review
marvil07’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +DX

Reroll seems fine and still applies.

tim.plunkett’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committing under the reduced fragility provision of the beta evaluation. Committed 5d36a99 and pushed to 8.0.x. Thanks!

  • alexpott committed 5d36a99 on 8.0.x
    Issue #2174507 by jessebeach, alansaviolobo, tim.plunkett: Make debug()...

Status: Fixed » Closed (fixed)

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