php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41930 Error strings are trimmed in custom error handlers for catchable fatal errors
Submitted: 2007-07-08 23:56 UTC Modified: 2007-07-09 14:58 UTC
From: andrea dot barani at tin dot it Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.3 OS: Windows Vista (32bit)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andrea dot barani at tin dot it
New email:
PHP Version: OS:

 

 [2007-07-08 23:56 UTC] andrea dot barani at tin dot it
Description:
------------
Error strings are trimmed out in custom error handlers for catchable fatal errors.
This following code uses type hinting available in Php 5 to produce a recoverable error. As you can see the last part of the error string is missing.
This code has been tested under different conditions and paths, the string is always trimmed after the word 'defined'.

Reproduce code:
---------------
<?php

function handler($errno, $errstr)
{
	echo $errstr;
}
set_error_handler('handler');

class Test1
{
	public function __construct(Test3 $variable)
	{
	}
}
class Test2
{
}

$test2 = new Test2;
$test1 = new Test1($test2);

?>

Expected result:
----------------
Argument 1 passed to Test1::__construct() must be an instance of Test3, instance of Test2 given, called in D:\Web\test.php on line 20 and defined in D:\Web\test.php on line 11

Actual result:
--------------
Argument 1 passed to Test1::__construct() must be an instance of Test3, instance of Test2 given, called in D:\Web\test.php on line 20 and defined

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-09 14:13 UTC] jani@php.net
Your error handler is just incomplete, here's how it works:

<?php

function handler($errno, $errstr, $errfile, $errline)
{
    echo $errstr, " on line $errline in file $errfile";
}
set_error_handler('handler');

class Test1
{
    public function __construct(Test3 $variable)
    {
    }
}
class Test2
{
}

$test2 = new Test2;
$test1 = new Test1($test2);

 [2007-07-09 14:58 UTC] andrea dot barani at tin dot it
Ok, I was confused by the fact that most of the standard error messages are in fact complete senteces. I thought the last words were part of the message itself.

I apologize for the mistake. :)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 28 11:00:03 2025 UTC