php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66843 set_error_handler message is cut
Submitted: 2014-03-07 12:39 UTC Modified: 2014-03-28 20:16 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: php at maisqi dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.5.10 OS: Windows and Linux
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: php at maisqi dot com
New email:
PHP Version: OS:

 

 [2014-03-07 12:39 UTC] php at maisqi dot com
Description:
------------
The message passed to the function registered with set_error_handler is sometimes cut. I tested the error reporting with or without set_error_handler() and the message is incomplete on the latter.

Test script:
---------------
<pre>
<?php
ini_set ('display_errors', '1');

echo "<h2>With no set_error_handler()</h2>\n";
test ();

echo "<h2>With the set_error_handler() setup</h2>\n";
set_error_handler (function ($code, $message) {	echo '== ', htmlspecialchars ($message);	});
test ();

echo "\n\n\n\nDone";

function test ($a) {}

Expected result:
----------------
It should be output the exact same message two times.

Actual result:
--------------
The first message (with no set_error_handler() is ok; the second is trimmed after "defined".

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-03-07 12:41 UTC] php at maisqi dot com
Test script in http://maisqi.com/outros/bugs/php/66843, running on a Linux server.
 [2014-03-11 10:13 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2014-03-11 10:13 UTC] ab@php.net
Under Apache you should check if there's something in the error_log, sometimes that output will go to stderr so it'll be seen in the error logs only. Whereby what you show is probably not the case.

I assume the issue you've got is laying in the usage of htmlspecialchars. Please check your error messages are in the right charset.

Thanks.
 [2014-03-11 16:22 UTC] php at maisqi dot com
-Status: Feedback +Status: Open
 [2014-03-11 16:22 UTC] php at maisqi dot com
@ab@php.net
Thanks for your help but I don't think that's the problem. I changed the script on the server to output error log: http://maisqi.com/outros/bugs/php/66843
The message of the error log is being output fully, so it can't be an issue with the character encoding, or both would be truncated.
 [2014-03-25 14:25 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2014-03-25 14:25 UTC] ab@php.net
But have you tried to remove the htmlspecialchars() call?

Thanks.
 [2014-03-25 19:53 UTC] php at maisqi dot com
-Status: Feedback +Status: Open
 [2014-03-25 19:53 UTC] php at maisqi dot com
I tested it now without htmlspecialchars() and the problem remains. Check the file for yourself; it outputs the source code now.
Thanks.
 [2014-03-26 08:23 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2014-03-26 08:23 UTC] ab@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

Please use the full parameter list of the error handler function, that way you can compose the error message.

set_error_handler (function ($code, $message, $file, $line) {	echo '== ', $message, ' in ', $file, ' on line ', $line;	});
 [2014-03-26 20:20 UTC] php at maisqi dot com
I'm using PHP 5.5.10. Check the script again; it's printing the PHP_VERSION now.
 [2014-03-26 21:33 UTC] requinix@php.net
"Missing argument 1 for test(), called in /home/maisqic/public_html/outros/bugs/php/66843.php on line 13 and defined" IS the complete $message - the "in <file> on line <line>" is added by the built-in error handlers automatically. Your custom handler is not doing that.

Use the code @ab posted and you'll get the output you're expecting.
 [2014-03-28 20:16 UTC] php at maisqi dot com
Hello, requinix@php.net.
That's is a very strange thing to do, IMO, but I'm not going to waste anyone's time in such a minor detail. Closing this issue in my mind. Thanks.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 08:00:02 2026 UTC