Ilia Alshanetsky wrote:
> I've discussed this issue with Andrei at least a month ago (if not
> longer) when the patch was originally added, and I believe that the
> introduced behavior is the correct one.

IMO correct or not depends on the context where the function is used.

At least, as array_unique() was not capable of dealing with objects
before the Andrei's patch, every existing code should use it with
strings, not objects.

If SORT_REGULAR could handle objects as well as strings in the same
manner as SORT_STRING I wouldn't see any problem, although it cannot.

Moriyoshi


> 
> On 14-Feb-09, at 9:12 PM, Moriyoshi Koizumi wrote:
> 
>> So, what are RM's thoughts on this? My points are:
>>
>> 1. Making SORT_REGULAR default *actually* broke existing code.
>> 2. Adding the second argument addressed the problem enough that the
>> elements are treated indifferently when used with objects.
>>
>> Regards,
>> Moriyoshi
>>
>> Moriyoshi Koizumi wrote:
>>> Whatever reasoning, I don't think it's a good idea to revert someone
>>> else's patch before discussing anything.
>>>
>>> Aside from this, I agree with you the old behavior is that stupid, but
>>> BC should always be honored.
>>>
>>> Moriyoshi
>>>
>>> Andrei Zmievski wrote:
>>>> Don't do this please. Why did you feel the need to go back and
>>>> change my
>>>> patch including the NEWS entry? I knew what I was doing when I set the
>>>> default behavior to SORT_REGULAR and this was discussed with both 5.3
>>>> and 5.2 RMs. With your change it'l back to the stupid  old behavior of:
>>>>
>>>> $array = array(new stdClass(), new stdClass(), new Foo());
>>>> $array = array_unique($array);
>>>>
>>>> And now $array has only 1 element. I really hate having tell PHP not to
>>>> be stupid, rather than having it default to being smart.
>>>>
>>>> I'm going to revert this.
>>>>
>>>> -Andrei
>>>>
>>>> Moriyoshi Koizumi wrote:
>>>>> moriyoshi        Thu Feb 12 18:29:15 2009 UTC
>>>>>
>>>>>  Modified files:                  /php-src/ext/standard    array.c
>>>>> Log:
>>>>>  * Fix bug #47370 (BC breakage of array_unique())
>>>>>
>>>>> http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.471&r2=1.472&diff_format=u
>>>>>
>>>>>
>>>>> Index: php-src/ext/standard/array.c
>>>>> diff -u php-src/ext/standard/array.c:1.471
>>>>> php-src/ext/standard/array.c:1.472
>>>>> --- php-src/ext/standard/array.c:1.471    Mon Feb  9 10:47:19 2009
>>>>> +++ php-src/ext/standard/array.c    Thu Feb 12 18:29:15 2009
>>>>> @@ -21,7 +21,7 @@
>>>>>
>>>>> +----------------------------------------------------------------------+
>>>>>
>>>>> */
>>>>>
>>>>> -/* $Id: array.c,v 1.471 2009/02/09 10:47:19 dmitry Exp $ */
>>>>> +/* $Id: array.c,v 1.472 2009/02/12 18:29:15 moriyoshi Exp $ */
>>>>>
>>>>> #include "php.h"
>>>>> #include "php_ini.h"
>>>>> @@ -2924,7 +2924,7 @@
>>>>>     };
>>>>>     struct bucketindex *arTmp, *cmpdata, *lastkept;
>>>>>     unsigned int i;
>>>>> -    long sort_type = PHP_SORT_REGULAR;
>>>>> +    long sort_type = PHP_SORT_STRING;
>>>>>
>>>>>     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l",
>>>>> &array, &sort_type) == FAILURE) {
>>>>>         return;
>>>>>
>>>>>
>>>>>
>>>
>>>
>>
> 
> Ilia Alshanetsky
> 
> 
> 
> 


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to