Re: Re: hex2bin: E_WARNING is too much for odd string?

From: Date: Fri, 28 Jun 2013 09:21:04 +0000
Subject: Re: Re: hex2bin: E_WARNING is too much for odd string?
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-68002@lists.php.net to get a copy of this message
On 2013-06-27 03:33, Sherif Ramadan wrote:
On Wed, Jun 26, 2013 at 9:05 PM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
Hi all, I've sent pull request for PHP-5.5 branch. https://github.com/php/php-src/pull/369 It's simple 1 liner removes E_WARNING for invalid length. Are there any objections?
Yes, I object to removing the error in the same breath we're arguing for consistency. 5.4.0 through 5.4.3 (no error), 5.4.4 through 5.4.16 (error), 5.5.0 (error), 5.5.1 (no error)??? What kind of consistency is this? I thought you wanted to add an extra error for malformed hex, which I would have been fine with, but removing the error entirely? The error is useful. It informs the user that they may have buggy code since the function is clearly documented to expect even length hex encoded strings.
In my opinion generating E_WARNING is too severe. Passing improper string to hex2bin does not necessary mean "buggy code". If the string is eg. from external input, why should I check if it's a well formed hex string if the function does this anyway? I think E_NOTICE + returning false is enough. And about consistency... I don't know the rationale behind adding E_ERROR in recent versions, but if the situation is bad, it should be fixed, not proliferated to next versions. Yes, it'd better if the change was better thought, but the milk has spilled. --Leszek

« previous php.internals (#68002) next »