Follow-up #2853359: Runtime debug statement in Views now prints out object:
@Lendude:
Printing debug information on a live system feels wrong. Looks like Views is the only place in core where this currently happens outside of tests, so should we maybe take them all out?
\Drupal\views\Plugin\views\field\FieldPluginBase::addAdditionalFields
\Drupal\views\Plugin\views\style\Opml::render
\Drupal\views\Plugin\views\style\Rss::render
\Drupal\views\Plugin\views\style\StylePluginBase::render
@dawehner
This code is probably coming from Drupal 6, where exceptions weren't really a thing, given views was compatible with php 4.
@Lendude
IMO debug statements should not live in core code and as @dawehner pointed out in #11, this is probably a leftover from D6/PHP4 times, so it could do with an update to more current best practice.
Problem/Motivation
debug() has worked its way (for live in core code), and is no longer the best practice.
We have also few other problem with debug:
- #2844732: Drupal treats all user-level PHP notices as debug messages
- #2692867: debug() statement causes caches to be ignored, hence debug() in a failing test suddenly causes it to pass
- #2552163: Do not use FormattableMarkup in exceptions, trigger_error, and debug (the second pass)
Proposed resolution
- Smooth replacement through the trigger_error.
- Replace on other tools, like #2096815: Replace debug() output with Krumo
- Repair, like #2795567: Use Symfony's VarDumper for easier test debugging with dump()
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 2904847-4.patch | 3.51 KB | mglaman |
Comments
Comment #1
Anonymous (not verified) commentedvaplas created an issue. See original summary.
Comment #2
Anonymous (not verified) commentedComment #4
mglamanReplaces
debug()withtrigger_errordirectly.Comment #5
borisson_I don't see other non-test places where this is used.
Comment #6
alexpottCommitted 566b7aa and pushed to 8.6.x. Thanks!