[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    Re: PHP > v7.2.18 preg_match returns 2
From:       "Christoph M. Becker" <cmbecker69 () gmx ! de>
Date:       2019-11-21 11:52:38
Message-ID: ef4c1fb2-059c-410b-3173-788b66880113 () gmx ! de
[Download RAW message or body]

On 19.11.2019 at 15:16, Christoph M. Becker wrote:

> On 19.11.2019 at 14:25, Falko Matthies wrote:
>
>> just found out, that function preg_match() returns not only 1 or boolea=
n values. I did not find any documentation about
>> some changes of this method and also the documentation is still the sam=
e.. So either there are undocumented changes or it
>> is a small bug.
>>
>> Documentation: https://www.php.net/manual/en/function.preg-match.php#re=
fsect1-function.preg-match-returnvalues
>>
>> Tested locally with PHP 7.3.11-1+0~20191026.48+debian10~1.gbpf71ca0
>>
>>     <?php
>>     var_dump(preg_match('/^|\d{1,2}$/', "7"));  // expected: int(1), go=
t: int(2)
>>
>>
>> Also a small test at http://sandbox.onlinephpfunctions.com/ showed a re=
sult change between PHP v7.2.18 and v7.3.5. I
>> have checked the bugs and the changelog but could not find any notes.
>
> This also happens on <https://3v4l.org/cKarY>, but only as of 7.3.0 (not
> 7.2).  On a quick glance, it looks like this line[1] should rather be
>
>   RETVAL_LONG(global ? matched : MIN(matched, 1));
>
> Anyhow, I suggest to file a bug report on <https://bugs.php.net/>
> (assuming that this issue has not been reported already).
>
> [1]
> <https://github.com/php/php-src/blob/php-7.3.11/ext/pcre/php_pcre.c#L141=
3>

I have filed that as <https://bugs.php.net/78853> just now.

Thanks,
Christoph
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic