Like I said in the bug report: THERE IS NO BC issue here. If any function changes input parameters it's a bug if the function is not supposed to do that!

--Jani


Nuno Lopes [EMAIL PROTECTED] kirjoitti:
I think this change is too intrusive for a bug fix only branch. This introduces a little BC break (to better match the manual description), so I think it should only go with 5.3.
Nuno


----- Original Message -----
> Doesn't this bug exist in PHP_5_2 branch? That's not (AFAIK) dead branch > yet so bug fixes MUST go there too.
> In which case you move that NEWS entry to the PHP_5_2 NEWS..
>
> --Jani
>
> Nuno Lopes [EMAIL PROTECTED] kirjoitti:
>> nlopess Thu Aug 14 13:12:42 2008 UTC
>>
>>   Added files:                 (Branch: PHP_5_3)
>> /php-src/ext/pcre/tests bug44925.phpt Modified files: >> /php-src NEWS /php-src/ext/pcre php_pcre.c Log:
>>   Fixed bug #44925 (preg_grep() modifies input array)
>> >> http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.268&r2=1.2027.2.547.2.965.2.269&diff_format=u
>> Index: php-src/NEWS
>> diff -u php-src/NEWS:1.2027.2.547.2.965.2.268 >> php-src/NEWS:1.2027.2.547.2.965.2.269
>> --- php-src/NEWS:1.2027.2.547.2.965.2.268 Thu Aug 14 10:13:23 2008
>> +++ php-src/NEWS Thu Aug 14 13:12:42 2008
>> @@ -30,6 +30,7 @@
>> - Fixed bug #45545 (DateInterval has 4 char limitation for ISO >> durations).
>>    (Derick)
>>  - Fixed bug #45044 (relative paths not resolved correctly). (Dmitry)
>> +- Fixed bug #44925 (preg_grep() modifies input array). (Nuno)
>> - Fixed bug #44100 (Inconsistent handling of static array declarations >> with
>>    duplicate keys). (Dmitry)
>>  - Fixed bug #43817 (opendir() fails on Windows directories with parent
>> 
http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/php_pcre.c?r1=1.168.2.9.2.21.2.19&r2=1.168.2.9.2.21.2.20&diff_format=u
>> Index: php-src/ext/pcre/php_pcre.c
>> diff -u php-src/ext/pcre/php_pcre.c:1.168.2.9.2.21.2.19 >> php-src/ext/pcre/php_pcre.c:1.168.2.9.2.21.2.20 >> --- php-src/ext/pcre/php_pcre.c:1.168.2.9.2.21.2.19 Sat Aug 2 04:46:06 >> 2008
>> +++ php-src/ext/pcre/php_pcre.c Thu Aug 14 13:12:42 2008
>> @@ -16,7 +16,7 @@
>> >> +----------------------------------------------------------------------+
>>   */
>> -/* $Id: php_pcre.c,v 1.168.2.9.2.21.2.19 2008/08/02 04:46:06 felipe Exp >> $ */ >> +/* $Id: php_pcre.c,v 1.168.2.9.2.21.2.20 2008/08/14 13:12:42 nlopess Exp >> $ */
>>  #include "php.h"
>>  #include "php_ini.h"
>> @@ -1743,13 +1743,30 @@
>>  /* Go through the input array */
>>  zend_hash_internal_pointer_reset(Z_ARRVAL_P(input));
>> - while(zend_hash_get_current_data(Z_ARRVAL_P(input), (void **)&entry) == >> SUCCESS) { >> + while (zend_hash_get_current_data(Z_ARRVAL_P(input), (void **)&entry) >> == SUCCESS) {
>> + zend_bool is_copy;
>> + zval *str;
>> +
>> + switch (Z_TYPE_PP(entry)) {
>> + case IS_STRING:
>> + is_copy = 0;
>> + str = *entry;
>> + break;
>> +
>> + default:
>> + is_copy = 1;
>>  - convert_to_string_ex(entry);
>> + ALLOC_ZVAL(str);
>> + Z_ADDREF_PP(entry); /* the function below decreases the ref counting */
>> + COPY_PZVAL_TO_ZVAL(*str, *entry);
>> +
>> + convert_to_string(str);
>> + break;
>> + }
>>  /* Perform the match */
>> - count = pcre_exec(pce->re, extra, Z_STRVAL_PP(entry),
>> -   Z_STRLEN_PP(entry), 0,
>> + count = pcre_exec(pce->re, extra, Z_STRVAL_P(str),
>> +   Z_STRLEN_P(str), 0,
>>    0, offsets, size_offsets);
>>  /* Check for too many substrings condition. */
>> @@ -1762,25 +1779,30 @@
>>  }
>>  /* If the entry fits our requirements */
>> - if ((count > 0 && !invert) ||
>> - (count == PCRE_ERROR_NOMATCH && invert)) {
>> - Z_ADDREF_PP(entry);
>> + if ((count > 0 && !invert) || (count == PCRE_ERROR_NOMATCH && invert)) >> {
>> +
>> + if (!is_copy) {
>> + SEPARATE_ARG_IF_REF(str);
>> + }
>>  /* Add to return array */
>> switch (zend_hash_get_current_key(Z_ARRVAL_P(input), &string_key, >> &num_key, 0))
>>  {
>>  case HASH_KEY_IS_STRING:
>>  zend_hash_update(Z_ARRVAL_P(return_value), string_key,
>> - strlen(string_key)+1, entry, sizeof(zval *), NULL);
>> + strlen(string_key)+1, &str, sizeof(zval *), NULL);
>>  break;
>>  case HASH_KEY_IS_LONG:
>> - zend_hash_index_update(Z_ARRVAL_P(return_value), num_key, entry,
>> + zend_hash_index_update(Z_ARRVAL_P(return_value), num_key, &str,
>>     sizeof(zval *), NULL);
>>  break;
>>  }
>> + } else if (is_copy) {
>> + zval_dtor(str);
>> + FREE_ZVAL(str);
>>  }
>> - +
>>  zend_hash_move_forward(Z_ARRVAL_P(input));
>>  }
>>  zend_hash_internal_pointer_reset(Z_ARRVAL_P(input));
>>
>> 
http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/bug44925.phpt?view=markup&rev=1.1
>> Index: php-src/ext/pcre/tests/bug44925.phpt
>> +++ php-src/ext/pcre/tests/bug44925.phpt
>>
>>
>>
>> -- >> PHP CVS Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to