php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66860 Stack traces are unreadable
Submitted: 2014-03-09 13:00 UTC Modified: 2014-03-09 17:30 UTC
From: eldmannen+php at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: eldmannen+php at gmail dot com
New email:
PHP Version: OS:

 

 [2014-03-09 13:00 UTC] eldmannen+php at gmail dot com
Description:
------------
The stack traces are unreadable.
They already contain some markup such as <b> but are still pretty much unreadable due to all text on one line.

Wrap the stack trace in <pre> tags, or use <br> at the end of the lines.

Test script:
---------------
<?php

function a() {
    b();
}

function b() {
    c();
}

function c() {
    throw new Exception;
}

a();

Expected result:
----------------
Fatal error: Uncaught exception 'Exception' in /var/www/test.php:12
Stack trace:
#0 /var/www/test.php(8): c()
#1 /var/www/test.php(4): b()
#2 /var/www/test.php(15): a()
#3 {main}
  thrown in /var/www/test.php on line 12


Actual result:
--------------
Fatal error: Uncaught exception 'Exception' in /var/www/test.php:12 Stack trace: #0 /var/www/test.php(8): c() #1 /var/www/test.php(4): b() #2 /var/www/test.php(15): a() #3 {main} thrown in /var/www/test.php on line 12

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-03-09 16:40 UTC] phpmpan at mpan dot pl
The stack trace is properly formatted and broken into lines. You don't see it probably because you view it in a browser which treats this plain-text data as HTML and strips newlines.
 [2014-03-09 16:57 UTC] rasmus@php.net
-Status: Open +Status: Not a bug
 [2014-03-09 16:57 UTC] rasmus@php.net
.
 [2014-03-09 17:11 UTC] eldmannen+php at gmail dot com
@phpmpan,
Yes, and that would be the correct behaviour if I used php-cli, but I used php-cgi.

If I was not supposed to view in a web browser, then why does it contain markup such as <b> already?
 [2014-03-09 17:21 UTC] rasmus@php.net
Use error_prepend_string/error_append_string in your ini or in an ini_set() in your script if this bothers you.
 [2014-03-09 17:27 UTC] eldmannen+php at gmail dot com
That would be prepend/append <pre> tags around all the errors, not only the stack trace.

I see no reason why not to wrap the stack trace in <pre> or end each stack trace line with <br>.

Else, I think the error message should have <b> removed to be consistent.

What reason is there not to improve the markup?
Either improve the markup or remove the markup.
 [2014-03-09 17:30 UTC] eldmannen+php at gmail dot com
By the way, error_prepend_string and error_append_string ought to be deprecated and removed.

Does it really belong in the ini file?
Is there any reason it should be there?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC