php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41128 Trigger error fails if more than two parameters
Submitted: 2007-04-18 09:27 UTC Modified: 2007-04-18 10:28 UTC
From: catzwolf at zarilia dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.1 OS: windows
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: catzwolf at zarilia dot com
New email:
PHP Version: OS:

 

 [2007-04-18 09:27 UTC] catzwolf at zarilia dot com
Description:
------------
It seems in php 5.2.1 that there is a bug that will render your 'user errorhander' useless if you add more than 2 Parameters for the arguement.

Doing something like this will cause the trap to fail and not trapped. I don't think that this sort of behaviour would be by design, so a bug?

Reproduce code:
---------------
trigger_error( "oops we have a fatal error", E_USER_ERROR, __LINE_ );

Expected result:
----------------
I would expect the user errorhandler to trap the error and display it

Actual result:
--------------
It is ignored by the user error handler and php internal error handling displays the error instead.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-18 09:34 UTC] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

http://php.net/trigger_error
 [2007-04-18 09:55 UTC] catzwolf at zarilia dot com
Ok I fail to see the logic as why this would not be considered a bug? 

If a function only excepts 2 paramenters and works as expected and you add a 3rd (that shouldn't be there) then I would expect that function to ignore the 3rd parameter and still function as intended.

So what you are saying is this?

function security($foo, $bar) {
   return ($foo && $bar ) ? true :false;
}

security(1,1);

This function would return true, but if we did this?

security(1,1,1);

It would return false? Even though there is no 3rd parameter in the function. Sorry but that isn't logical at all and any script that requires this to work correctly would fail all because of a 3rd value that shouldn't be there?

Because that is what is happening with trigger_error.
 [2007-04-18 10:06 UTC] tony2001@php.net
>If a function only excepts 2 paramenters and works as expected 
>and you add a 3rd (that shouldn't be there) then I would expect 
>that function to ignore the 3rd parameter and still function as intended.

Your expectations are wrong, none of internal funcs work this way.
They have certain number of required and accepted parameters and passing more arguments than can accepted is clearly your mistake.
 [2007-04-18 10:28 UTC] catzwolf at zarilia dot com
That is my whole point,it was a mistake on my part and it took me half an hour trying to find out why my errorhandler was not working correctly. When I removed the 3rd parameter from the function it worked as it should. Adding that third value totally rendered this function unworkable. 

Did you even test this? Did you even go and see how this error affects the workablity of this function?

Anyway thanks for your time.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Dec 04 08:00:01 2025 UTC