Documentation

Quick Stack View block

Add the Quick Stack View block to a page and it will provide a formatted stack backtrace from the block. 

In the edit dialogue you can select where the backtrace will begin:

  • Block controller view() method
  • Block view.php file

For syntax formatted output, you may also want to install the Highlighted Code Block.

Also in the edit dialogue you can select who can see the backtrace:

  • Anyone
  • Page Owner
  • Specified User
  • User Group

Security Warning: Leaving backtrace information visible on any publicly viewable web site could help a hacker break into your site.

Format Trace helper

The disadvantage of the Quick Stack View block is that you only get the trace from inside that block. If you are developing a block, block template or single page and want to quickly add a stack backtrace, simply insert the following code into the block view, single page view or template.

echo  Loader::helper('format_trace', 'jl_quick_stack_view')->fmt();

Or more verbosely:

$backtrace = debug_backtrace();
$trh = Loader::helper('format_trace', 'jl_quick_stack_view');
echo $trh->fmt($backtrace);

The first form of the above will generate a backtrace from within the helper. The second form will show the backtrace from wherever you make the call to debug_backtrace().

Core error_fatal.php override file

When installed, this override will provide Quick Stack View diagnostics to the core fatal error report.

Within the Quick Stack View package is the file "elements/error_fatal.php". To install the override, this must be manually copied into "site_root/elements/error_fatal.php". There is no automatic installation of this override.

In some circumstances, particularly where the original error is within a block save, formatting may be stripped from the stack trace. In this situation, the full stack trace can be viewed in the developer console, either as text within the dom element, or as a response within the network tab.

DANGER

This override breaks one of the fundamental principles of error reporting, in that it adds considerable complexity to the reporting mechanism. Be prepared to remove this override if you encounter errors that cause the reporting to break.

This override is also rather naughty in loading jQuery directly in the code. Again, on sites that are configured to load from a CDN, just doing that could cause script errors.

YOU HAVE BEEN WARNED !!!

 

Under the Hood

Internally Quick Stack View uses the php debug_backtrace() function. You may also find it useful to read the how-to concrete5 php debug clips.

Learning about concrete5

A stack backtrace can be a useful starting point when leaning about how concrete5 works to render blocks, block templates and single pages.

You will soon discover that the backtrace is different depending on whether you place the block directly on a page, in a stack, or pull it from another page using an addon like Universal Content puller.

The backtrace is also different depending on what option you choose to start:

  • Block controller view() method
  • Block view.php file