Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 4 years ago

#43292 closed enhancement (invalid)

Add dd() function for debugging

Reported by: danieltj's profile danieltj Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9.4
Component: General Keywords: has-patch
Focuses: Cc:


Definitely a low priority task, however I feel that including a dd() function in Core would be great for debugging quickly and efficiently. I find myself needing to use this but not wanting to including it in every bit of work I do as it's pointless to have it for individual projects.

dd stands for dump and die. The PHP framework, Laravel has this function built in which accepts one parameter of a variable, will call var_dump() with the variable and immediately call die() to stop script execution.

Can this be added as it's a small and simple function that is very handy to have for testing.

Attachments (1)

43292.diff (638 bytes) - added by danieltj 6 years ago.
Basic function use-case.

Download all attachments as: .zip

Change History (6)

6 years ago

Basic function use-case.

#1 @danieltj
6 years ago

  • Keywords has-patch dev-feedback added

Added 43292.diff which demonstrates how this could be implemented and altered by plugins on an as-needed basis.

#2 @Mte90
6 years ago

I think that is can be very highly opinionated.
As example I don't use the browser to print stuff but the log so I can use the same code also in production or somewhere without the risk of break something with error_log(print_r($var,true));.

Also for the debug there are a lot of plugins that help on that like Query monitor or Debug bar that implement this kind of things.

PS: There is also xDebug as option.

#3 @ocean90
6 years ago

I don't see the proposed function helpful for debugging, at least not without xDebug enabled.

Related: #33740, #30934

#4 @danieltj
6 years ago

  • Keywords dev-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

I understand what you both mean. I suppose if the intention is to never have this used on a live site, it's technically a wasted function as it'll never be present with any usable code except for debugging. Probably best to include in any testing tools locally, thanks for sharing your thoughts. :)

#5 @SergeyBiryukov
4 years ago

#49780 was marked as a duplicate.

Note: See TracTickets for help on using tickets.