Bug #53724 [Com]: array_diff like methods compares false as identity and true as equal
Edit report at http://bugs.php.net/bug.php?id=53724&edit=1 ID: 53724 Comment by: lukas dot starecek at centrum dot cz Reported by:lukas dot starecek at centrum dot cz Summary:array_diff like methods compares false as identity and true as equal Status: Open Type: Bug Package:Arrays related Operating System: Irrelevant PHP Version:5.3.5 Block user comment: N Private report: N New Comment: Ah I did not noticed this "grey" part of method documentation in examples. You are right, documentation says it, but imho in not so clear way. I have read only specifications, not examples. Imho documentation could be a little bit more exact, because this is important. So sadly this functions are designed only for string comparison, not for general variable comparison :-/ . My fault, bogus, sorry. But think about functions of this kind for general variables comparison, not only for string comparison :-) . Previous Comments: [2011-02-20 16:20:18] tbrasta at gmail dot com This is not a bug. The function is operating exactly as stated in the documentation, i.e. casted to string values are compared. Since (string) 0 = "0", (string) false = "" and (string) "0" = "0" but "0" !== "", you get the result as it should be. ------------------------ [2011-01-12 14:27:34] lukas dot starecek at centrum dot cz A little mistake, '' behaves as same with false, so problem is only in comparing 0 and '0' (and maybee some other variables I did not used). ------------------------ [2011-01-12 14:16:39] lukas dot starecek at centrum dot cz Description: array_diff functions compares boolean false as identity (operator "===") and boolean true as equal (operator "==") so behaves inconsistently. It should compare all values in same way and in my opinion it should compare as equals ("==") or have argument (or another mechanism) how to set whether compare by equal or identity. As example I use array_diff_assoc but I think it will probably behave simmilary with another array realted functions (array_diff%, array_intersect%). In expected result I suppose comparing as equal (operator '=='). In example you can see, that array_diff_assoc behaves in such way that 0 or '0' or '' is not same as false, but 1 or '1' is same as true. So false is compared like '===' and true is compared like '=='. Because 0 is same as '0' and 1 is same as '1' I suppose, that this problem is only for boolean false value. Test script: --- $arr1 = array('a' => 0, 'b' => 1,'c' => '0', 'd' => '1', 'e' => '','f' => false, 'g' => true, 'h' => 0, 'i' => 1); $arr2 = array('a' => false, 'b' => true, 'c' => false, 'd' => true, 'e' => false, 'f' => false, 'g' => true, 'h' => '0', 'i' => '1'); var_dump(array_diff_assoc($arr1, $arr2)); Expected result: array(0) { } Actual result: -- array(2) { ["a"]=> int(0) ["c"]=> string(1) "0" } -- Edit this bug report at http://bugs.php.net/bug.php?id=53724&edit=1
Bug #53724 [Opn]: array_diff like methods compares false as identity and true as equal
Edit report at http://bugs.php.net/bug.php?id=53724&edit=1 ID: 53724 User updated by:lukas dot starecek at centrum dot cz Reported by:lukas dot starecek at centrum dot cz Summary:array_diff like methods compares false as identity and true as equal Status: Open Type: Bug Package:Arrays related Operating System: Irrelevant PHP Version:5.3.5 Block user comment: N Private report: N New Comment: A little mistake, '' behaves as same with false, so problem is only in comparing 0 and '0' (and maybee some other variables I did not used). Previous Comments: ---- [2011-01-12 14:16:39] lukas dot starecek at centrum dot cz Description: array_diff functions compares boolean false as identity (operator "===") and boolean true as equal (operator "==") so behaves inconsistently. It should compare all values in same way and in my opinion it should compare as equals ("==") or have argument (or another mechanism) how to set whether compare by equal or identity. As example I use array_diff_assoc but I think it will probably behave simmilary with another array realted functions (array_diff%, array_intersect%). In expected result I suppose comparing as equal (operator '=='). In example you can see, that array_diff_assoc behaves in such way that 0 or '0' or '' is not same as false, but 1 or '1' is same as true. So false is compared like '===' and true is compared like '=='. Because 0 is same as '0' and 1 is same as '1' I suppose, that this problem is only for boolean false value. Test script: --- $arr1 = array('a' => 0, 'b' => 1,'c' => '0', 'd' => '1', 'e' => '','f' => false, 'g' => true, 'h' => 0, 'i' => 1); $arr2 = array('a' => false, 'b' => true, 'c' => false, 'd' => true, 'e' => false, 'f' => false, 'g' => true, 'h' => '0', 'i' => '1'); var_dump(array_diff_assoc($arr1, $arr2)); Expected result: array(0) { } Actual result: -- array(2) { ["a"]=> int(0) ["c"]=> string(1) "0" } -- Edit this bug report at http://bugs.php.net/bug.php?id=53724&edit=1
[PHP-BUG] Bug #53724 [NEW]: array_diff like methods compares false as identity and true as equal
From: Operating system: Irrelevant PHP version: 5.3.5 Package: Arrays related Bug Type: Bug Bug description:array_diff like methods compares false as identity and true as equal Description: array_diff functions compares boolean false as identity (operator "===") and boolean true as equal (operator "==") so behaves inconsistently. It should compare all values in same way and in my opinion it should compare as equals ("==") or have argument (or another mechanism) how to set whether compare by equal or identity. As example I use array_diff_assoc but I think it will probably behave simmilary with another array realted functions (array_diff%, array_intersect%). In expected result I suppose comparing as equal (operator '=='). In example you can see, that array_diff_assoc behaves in such way that 0 or '0' or '' is not same as false, but 1 or '1' is same as true. So false is compared like '===' and true is compared like '=='. Because 0 is same as '0' and 1 is same as '1' I suppose, that this problem is only for boolean false value. Test script: --- $arr1 = array('a' => 0, 'b' => 1,'c' => '0', 'd' => '1', 'e' => '','f' => false, 'g' => true, 'h' => 0, 'i' => 1); $arr2 = array('a' => false, 'b' => true, 'c' => false, 'd' => true, 'e' => false, 'f' => false, 'g' => true, 'h' => '0', 'i' => '1'); var_dump(array_diff_assoc($arr1, $arr2)); Expected result: array(0) { } Actual result: -- array(2) { ["a"]=> int(0) ["c"]=> string(1) "0" } -- Edit bug report at http://bugs.php.net/bug.php?id=53724&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53724&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53724&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53724&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53724&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53724&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53724&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53724&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53724&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53724&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53724&r=support Expected behavior: http://bugs.php.net/fix.php?id=53724&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53724&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53724&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53724&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53724&r=php4 Daylight Savings:http://bugs.php.net/fix.php?id=53724&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53724&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53724&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53724&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53724&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53724&r=mysqlcfg
Bug #49355 [Com]: Unable to properly fold To/Subject in emails
Edit report at http://bugs.php.net/bug.php?id=49355&edit=1 ID: 49355 Comment by: lukas dot starecek at centrum dot cz Reported by: php dot net at chris dot cs278 dot org Summary: Unable to properly fold To/Subject in emails Status: Open Type: Bug Package: Mail related Operating System: win32 only PHP Version: 5.2.10 New Comment: We have same problem on *nix system with PHP 5.1.6 and PHP 5.3.2. In mail function is allowed to use only \r\n to separate chunks of subject, but email with this subject is damaged when processed by microsoft SMTP server (I think some kind of exchange server). In damaged email are chunks of subjects followed by two new lines, which means end of header. Below you can see broken email headers. The part after "MIME-Version: 1.0" is supposed to be message body, but you can se fragments of second and following lines of chunked subject, and email headers, which was after subject in original email. -- Received: from * (*) by * (*) with Microsoft SMTP Server (TLS) id 8.1.393.1; Wed, 19 May 2010 15:03:47 +0200 Received: from * (*) by * (*) with Microsoft SMTP Server id 8.2.176.0; Wed, 19 May 2010 15:03:45 +0200 Received: by * (Postfix, from userid 48)id 72D6A36C2D; Wed, 19 May 2010 15:03:53 +0200 (CEST) From: infooma <*> To: * Date: Wed, 19 May 2010 15:03:45 +0200 Subject: =?Windows-1252?Q?Spam=5Fcsc:_POZOR!!_JEDN=C1_SE_O_TESTOVAC=CD_NOTIFIKACI_?= =?Windows-1252?Q?=8EoP_?= Thread-Topic: =?Windows-1252?Q?Spam=5Fcsc:_POZOR!!_JEDN=C1_SE_O_TESTOVAC=CD_NOTIFIKACI_?= =?Windows-1252?Q?=8EoP_?= Thread-Index: Acr3U7hpsAXS9QjASjS/sZtv0YXFjg== Message-ID: <3167228c-f54a-4a6b-b6c7-c7c1e5dc6...@*> X-MS-Exchange-Organization-AuthAs: Anonymous X-MS-Exchange-Organization-AuthSource: * X-MS-Has-Attach: X-MS-Exchange-Organization-SenderIdResult: None X-MS-Exchange-Organization-PCL: 2 X-MS-Exchange-Organization-PRD: * X-MS-TNEF-Correlator: received-spf: None (*: * does not designate permitted sender hosts) x-tm-as-product-ver: CSC-0-6.0.1038-17392 x-tm-as-result: Yes-9.62-7.00-31-1 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 =?UTF-8?B?MSBwcm9qZWt0dSBDWi4xLjEwLzIuMi4wMC8wNC4xMTExMSBieWxhIHDFmWVk?= =?UTF-8?B?w6FuYSBkbyBzdMOhZGlhICJTOC4xIEtvbnRyb2xhIDEuIHN0dXBuxJsgcHJv?= =?UTF-8?B?dmVkZW5hIi4=?= Received: from phpmailer ([*]) by * with HTTP (phpmailer); Wed, 19 May 2010 15:03:53 +0200 Date: Wed, 19 May 2010 15:03:53 +0200 From: * Message-ID: X-Priority: 3 X-Mailer: phpmailer [version 1.65] X-Mailer: PHP/5.1.6 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Previous Comments: [2009-08-25 09:47:20] php dot net at chris dot cs278 dot org Description: The SKIP_LONG_HEADER_SEP macro only permits CR-LF-WSP as a separator which works fine for SMTP, but sendmail under NIX requires LF as the new line character. The macro doesn't skip over LF-WSP which causes the LF to be replaced with a space, unfolding the header. This makes it near impossible to use UTF-8/etc. encoded strings for these headers. I posted to internals about this problem: http://marc.info/?l=php-internals&m=125110373328523&w=2 Reproduce code: --- mail('tes...@example.net', "Reproduction test e-mail for PHP bug breaking the correct wrapping\n of e-mails with long To/Subject headers.", 'Testing...'); Expected result: To: tes...@example.net Subject: Reproduction test e-mail for PHP bug breaking the correct wrapping of e-mails with long To/Subject headers. Testing... Actual result: -- To: tes...@example.net Subject: Reproduction test e-mail for PHP bug breaking the correct wrapping of e-mails with long To/Subject headers. Testing... -- Edit this bug report at http://bugs.php.net/bug.php?id=49355&edit=1
Req #44187 [Com]: mail() function and newlines
Edit report at http://bugs.php.net/bug.php?id=44187&edit=1 ID: 44187 Comment by: lukas dot starecek at centrum dot cz Reported by: anzenews at volja dot net Summary: mail() function and newlines Status: Open Type: Feature/Change Request Package: Feature/Change Request Operating System: any PHP Version: 5.2.5 New Comment: Be careful with that. There have to be newlines in subject if subject is too long (see RFC 2047), but there must not be two newlines consecutively (two consecutive new lines are header separator). Previous Comments: [2008-02-20 15:07:11] anzenews at volja dot net Description: Most of PHP users are unaware of security implications of such "Send to friend" scripts: I propose change of parameters to mail(): mail(array $to, string $subject, string $message[, array $additional_headers [, string $additional_parameters ]] ); The function should throw a warning if there is a newline anywhere, even inside arrays, and should not process the mail. I agree that the programmer should know its tools, BUT: - the fact is that most of PHP users don't - most of the TUTORIALS are insecure! A quick search for "PHP mail example" reveals many prominent pages with such examples. This is a huge problem and spammers are abusing it extensively. As this will undoubtedly break some of the scripts (though the fix should be easy) I suggest adding a configuration statement that enables such mail() behaviour, Reproduce code: --- Expected result: Warning: newline in mail() function, line... Mail not sent or everything after newline ignored. Actual result: -- Mail sent to m...@example.com and to y...@example.com. -- Edit this bug report at http://bugs.php.net/bug.php?id=44187&edit=1
#33732 [NEW]: behavior of constants in class and interface extending
From: lukas dot starecek at centrum dot cz Operating system: Linux PHP version: 5.0.3 PHP Bug Type: Feature/Change Request Bug description: behavior of constants in class and interface extending Description: If interface define any constants, then it's not possible (due to error) implement this interface in any class and extend any other class with this interface. Reproduce code: --- interface iA { const cA = 'const of iA'; } class A implements iA { } class B extends A implements iA { } $b = new B(); echo iA::cA; echo A::cA; echo B::cA; - Another example - interface iA { const cA = 'const of iA'; } class A implements iA { } interface iB extends iA { } class B extends A implements iB { } $b = new B(); echo iA::cA; echo A::cA; echo iB::cA; echo B::cA; Expected result: const of iA const of iA const of iA - Another example - const of iA const of iA const of iA const of iA Actual result: -- Fatal error: Cannot inherit previously-inherited constant cA from interface iA - Another example - Fatal error: Cannot inherit previously-inherited constant cA from interface iB -- Edit bug report at http://bugs.php.net/?id=33732&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33732&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33732&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33732&r=trysnapshot51 Fixed in CVS:http://bugs.php.net/fix.php?id=33732&r=fixedcvs Fixed in release:http://bugs.php.net/fix.php?id=33732&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33732&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33732&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33732&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33732&r=support Expected behavior: http://bugs.php.net/fix.php?id=33732&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33732&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33732&r=submittedtwice register_globals:http://bugs.php.net/fix.php?id=33732&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33732&r=php3 Daylight Savings:http://bugs.php.net/fix.php?id=33732&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33732&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33732&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33732&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33732&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33732&r=mysqlcfg