php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31955 Exception message length is limited
Submitted: 2005-02-13 17:20 UTC Modified: 2005-02-22 18:52 UTC
From: exaton at free dot fr Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5CVS-2005-02-13 (dev) OS: WinXP Pro SP2
Private report: No CVE-ID: None
 [2005-02-13 17:20 UTC] exaton at free dot fr
Description:
------------
[With PHP 5.0.4-dev Feb 13 2005 10:15:43 running on Apache 2.0.52 in Windows XP SP2]

It appears that Exceptions have some sort of limit on the length of their messages. When the message is too long, the throwing info is simply truncated, leaving only the "in <file> on line <line>" intact at the end.

Upon causing an Exception thus (sorry for the length, but it's the whole point) :

throw new Exception('0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678');

one will notice the truncature described. Adding more figures to the message will not change the incorrect output (truncature occurs at the same length). Shortening that message, on the other hand, will progressively "reveal" the rest of the throwing info.
(N.B. : because of HTML whitespace this is not evident until the message is shortened by at least 4 or 5 bytes).

In this instance, the limit is of 979 bytes in the message, for a total of 1127 bytes of HTML-decorated throwing info. These figures vary however, total throwing info 1161 bytes long, eg., having also been encountered, in another situation.

Said situation is a complex cause-exceptions handling part of my company's web development kit (much to long and involuted to present as reproduce code). Just saying that to explain how I came across such an error : the throwing info of cause exceptions, nested to arbitrary depth, can produce a very long message for the top Exception thrown.

Thank you for your time in solving this.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-22 11:05 UTC] tony2001@php.net
No, *all* error messages are limited to the value of log_errors_max_len.
For example, this code:
<?php
trigger_error(str_repeat("long string ", 10000), E_USER_ERROR);
?>
will not output "long string" 10000 times, the message you'll see will be truncated too.

Also, please note that messages are truncated only during the output, you still can get the original error message with call to $exception->getMessage() method.

So, you have to change log_errors_max_len option in your php.ini if you want to see full error messages that are longer than 1024 bytes (that's default value).
That's expected behaviour.
 [2005-02-22 18:52 UTC] exaton at free dot fr
Arg ! I know my php.ini directives but never linked this issue to log_errors_max_len... because it sounds like (and is described as, in comments) the maximum length of an error message as reproduced in an errorlog...

'twould be logical to trim the length of error messages in a log so as to avoid file bloat, without necessarily limiting the length of error output on a page... Hence my being misled.

Perhaps todo make the php.ini comment for this directive slightly more explicit ?

Thanks a lot for pointing this out, anyway.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 20:01:29 2024 UTC