Bug #49657 [Com]: array_search returns null instead of false

2012-06-30 Thread phillip dot berndt at googlemail dot com
Edit report at https://bugs.php.net/bug.php?id=49657edit=1

 ID: 49657
 Comment by: phillip dot berndt at googlemail dot com
 Reported by:pvenakis at efrontlearning dot net
 Summary:array_search returns null instead of false
 Status: Not a bug
 Type:   Bug
 Package:Unknown/Other Function
 Operating System:   windows
 PHP Version:5.3.0
 Block user comment: N
 Private report: N

 New Comment:

I disagree. This function returning NULL is nothing I'd expect. Especically 
since this behavior still (it's 2012!) is not documented. This IS a bug. If not 
because of the feature, at least one regarding missing documentation.

In PHP 4.2, you changed this function such that it returns FALSE in case of an 
error, which, as was pointed out above by the other commenter, is good, because 
it makes existence checking easy. Since FALSE !== NULL, things get pretty 
complicated now.


Previous Comments:

[2011-11-26 16:11:57] rodrigovb at gmail dot com

I'd like to advise you about the impact of this change in the company I work. 
Based on the last return value (FALSE) we had 40 php files with some lines 
checking the result of array_search (=== false). This is a small company with 
30 employees (and 40 php files to be changed). 

The concern of the owner is if PHP is sustainable enough to keep investing in 
develop instead of maintenance due to this changes.

Please write the change log (or point the link with the log) cointaining the  
real needs of this ghange.
 
In my point of view the impact of return value changes of any function could be 
severe, specially in bigger companies.


[2009-09-25 07:14:46] pvenakis at efrontlearning dot net

Thanks for the quick response. It's fine that it returns null, but since this 
changed from 5.2 to 5.3 it would be nice if it were mentioned in the changelog 
or in the documents. 
Best Regards, Periklis


[2009-09-24 12:17:22] paj...@php.net

That's expected. Returning NULL on invalid argument(s) is correct.


[2009-09-24 12:03:47] pvenakis at efrontlearning dot net

Description:

array_search returns false in 5.2.x, null in 5.3.0, when $haystack is not an 
array


Reproduce code:
---
$haystack = false; //Anything not an array
$result = array_search(1, $haystack);
var_dump($result);


Expected result:

bool(false)

Actual result:
--
null






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=49657edit=1


#38600 [Fbk-Opn]: Infinite loop in preg_match

2006-08-26 Thread phillip dot berndt at googlemail dot com
 ID:   38600
 User updated by:  phillip dot berndt at googlemail dot com
 Reported By:  phillip dot berndt at googlemail dot com
-Status:   Feedback
+Status:   Open
 Bug Type: PCRE related
 Operating System: Linux
 PHP Version:  5.1.5
 New Comment:

Same result for a fresh php5.2-200608261230 build.

I don't know, whether this helps, but in this build I interrupted the
process after about 10 seconds; here's the bt:

#0  adjust_recurse (group=0x84706db R, adjust=1, utf8=0,
cd=0xbfd088e0) at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:1117
#1  0x08080269 in compile_regex (options=0, oldims=0,
brackets=0xbfd084a4, codeptr=0xbfd08344, ptrptr=0xbfd0837c,
errorcodeptr=0xbfd084dc, lookbehind=0,
skipbytes=0, firstbyteptr=0x0, reqbyteptr=0x0, bcptr=0x3d,
cd=0xbfd088e0) at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:2681
#2  0x0807e71a in compile_regex (options=0, oldims=0,
brackets=0xbfd084a4, codeptr=0xbfd084a8, ptrptr=0xbfd084d8,
errorcodeptr=0xbfd084dc, lookbehind=0,
skipbytes=0, firstbyteptr=0x0, reqbyteptr=0x0, bcptr=0x3d,
cd=0xbfd088e0) at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:3177
#3  0x08081339 in php_pcre_compile2 (pattern=0xb7bdf6d8
(?!\\w)(0x[\\p{N}]+[lL]?|[\\p{Nd}]+(e[\\p{Nd}]*)?[lLdDfF]?)(?!\\w),
options=0, errorcodeptr=0x0,
errorptr=0xbfd089a4, erroroffset=0xbfd089a8, tables=0x8470220 )
at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:4983
#4  0x080829a3 in php_pcre_compile (pattern=0x0, options=0,
errorptr=0x0, erroroffset=0x0, tables=0x0)
at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:3905
#5  0x0808bfad in pcre_get_compiled_regex_cache (regex=0xb7be4bd4
/(?!\\w)(0x[\\p{N}]+[lL]?|[\\p{Nd}]+(e[\\p{Nd}]*)?[lLdDfF]?)(?!\\w)/,
regex_len=64)
at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/php_pcre.c:324
#6  0x0808d225 in php_do_pcre_match (ht=2, return_value=0xb7be4c20,
return_value_ptr=0x0, this_ptr=0x0, return_value_used=0, global=0)
at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/php_pcre.c:457
#7  0x082292d7 in zend_do_fcall_common_helper_SPEC
(execute_data=0xbfd08b60) at zend_vm_execute.h:200
#8  0x08228bdc in execute (op_array=0xb7be47d8) at
zend_vm_execute.h:92
#9  0x0820dabe in zend_execute_scripts (type=8, retval=0x0,
file_count=3) at
/home/pberndt/php_snap/php5.2-200608261230/Zend/zend.c:1095
#10 0x081cfb86 in php_execute_script (primary_file=0xbfd0b060) at
/home/pberndt/php_snap/php5.2-200608261230/main/main.c:1759
#11 0x082963b0 in main (argc=1, argv=0xbfd0b144) at
/home/pberndt/php_snap/php5.2-200608261230/sapi/cli/php_cli.c:1102


Previous Comments:


[2006-08-25 21:39:04] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip





[2006-08-25 21:14:47] phillip dot berndt at googlemail dot com

Description:

When executing the code below, the function won't return but loop
forever (or do something else, I don't know).

Reproduce code:
---
?php
$foo = 'bla bla bla';
   
preg_match('/(?!\w)(0x[\p{N}]+[lL]?|[\p{Nd}]+(e[\p{Nd}]*)?[lLdDfF]?)(?!\w)/',
$foo);
?

Expected result:

Something like that:

[EMAIL PROTECTED] ~ $ time perl -e '$_=bla bla bla;
/(?!\w)(0x[\p{N}]+[lL]?|[\p{Nd}]+(e[\p{Nd}]*)?[lLdDfF]?)(?!\w)/;'

real0m0.017s
user0m0.016s
sys 0m0.000s


Actual result:
--
[EMAIL PROTECTED] ~ $ php
?php
set_time_limit(10);
$foo = 'bla bla bla';
   
preg_match('/(?!\w)(0x[\p{N}]+[lL]?|[\p{Nd}]+(e[\p{Nd}]*)?[lLdDfF]?)(?!\w)/',
$foo);
?


Fatal error: Maximum execution time of 10 seconds exceeded in
/home/pberndt/- on line 4






-- 
Edit this bug report at http://bugs.php.net/?id=38600edit=1


#38600 [Opn]: Infinite loop in preg_match

2006-08-26 Thread phillip dot berndt at googlemail dot com
 ID:   38600
 User updated by:  phillip dot berndt at googlemail dot com
 Reported By:  phillip dot berndt at googlemail dot com
 Status:   Open
 Bug Type: PCRE related
 Operating System: Linux
 PHP Version:  5.1.5
 New Comment:

This should be the problem:

ChangeLog for PCRE
--
Version 6.7 04-Jul-06
[...]
 4. When UTF-8 mode was not set, PCRE looped when compiling certain
patterns
containing an extended class (one that cannot be represented by a
bitmap
because it contains high-valued characters or Unicode property
items, e.g.
[\pZ]). Almost always one would set UTF-8 mode when processing such
a
pattern, but PCRE should not loop if you do not (it no longer
does).
[Detail: two cases were found: (a) a repeated subpattern containing
an
extended class; (b) a recursive reference to a subpattern that
followed a
previous extended class. It wasn't skipping over the extended
class
correctly when UTF-8 mode was not set.]
[...]


Previous Comments:


[2006-08-26 13:40:16] phillip dot berndt at googlemail dot com

Same result for a fresh php5.2-200608261230 build.

I don't know, whether this helps, but in this build I interrupted the
process after about 10 seconds; here's the bt:

#0  adjust_recurse (group=0x84706db R, adjust=1, utf8=0,
cd=0xbfd088e0) at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:1117
#1  0x08080269 in compile_regex (options=0, oldims=0,
brackets=0xbfd084a4, codeptr=0xbfd08344, ptrptr=0xbfd0837c,
errorcodeptr=0xbfd084dc, lookbehind=0,
skipbytes=0, firstbyteptr=0x0, reqbyteptr=0x0, bcptr=0x3d,
cd=0xbfd088e0) at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:2681
#2  0x0807e71a in compile_regex (options=0, oldims=0,
brackets=0xbfd084a4, codeptr=0xbfd084a8, ptrptr=0xbfd084d8,
errorcodeptr=0xbfd084dc, lookbehind=0,
skipbytes=0, firstbyteptr=0x0, reqbyteptr=0x0, bcptr=0x3d,
cd=0xbfd088e0) at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:3177
#3  0x08081339 in php_pcre_compile2 (pattern=0xb7bdf6d8
(?!\\w)(0x[\\p{N}]+[lL]?|[\\p{Nd}]+(e[\\p{Nd}]*)?[lLdDfF]?)(?!\\w),
options=0, errorcodeptr=0x0,
errorptr=0xbfd089a4, erroroffset=0xbfd089a8, tables=0x8470220 )
at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:4983
#4  0x080829a3 in php_pcre_compile (pattern=0x0, options=0,
errorptr=0x0, erroroffset=0x0, tables=0x0)
at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:3905
#5  0x0808bfad in pcre_get_compiled_regex_cache (regex=0xb7be4bd4
/(?!\\w)(0x[\\p{N}]+[lL]?|[\\p{Nd}]+(e[\\p{Nd}]*)?[lLdDfF]?)(?!\\w)/,
regex_len=64)
at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/php_pcre.c:324
#6  0x0808d225 in php_do_pcre_match (ht=2, return_value=0xb7be4c20,
return_value_ptr=0x0, this_ptr=0x0, return_value_used=0, global=0)
at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/php_pcre.c:457
#7  0x082292d7 in zend_do_fcall_common_helper_SPEC
(execute_data=0xbfd08b60) at zend_vm_execute.h:200
#8  0x08228bdc in execute (op_array=0xb7be47d8) at
zend_vm_execute.h:92
#9  0x0820dabe in zend_execute_scripts (type=8, retval=0x0,
file_count=3) at
/home/pberndt/php_snap/php5.2-200608261230/Zend/zend.c:1095
#10 0x081cfb86 in php_execute_script (primary_file=0xbfd0b060) at
/home/pberndt/php_snap/php5.2-200608261230/main/main.c:1759
#11 0x082963b0 in main (argc=1, argv=0xbfd0b144) at
/home/pberndt/php_snap/php5.2-200608261230/sapi/cli/php_cli.c:1102



[2006-08-25 21:39:04] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip





[2006-08-25 21:14:47] phillip dot berndt at googlemail dot com

Description:

When executing the code below, the function won't return but loop
forever (or do something else, I don't know).

Reproduce code:
---
?php
$foo = 'bla bla bla';
   
preg_match('/(?!\w)(0x[\p{N}]+[lL]?|[\p{Nd}]+(e[\p{Nd}]*)?[lLdDfF]?)(?!\w)/',
$foo);
?

Expected result:

Something like that:

[EMAIL PROTECTED] ~ $ time perl -e '$_=bla bla bla;
/(?!\w)(0x[\p{N}]+[lL]?|[\p{Nd}]+(e[\p{Nd}]*)?[lLdDfF]?)(?!\w)/;'

real0m0.017s
user0m0.016s
sys 0m0.000s


Actual result:
--
[EMAIL PROTECTED] ~ $ php
?php
set_time_limit(10);
$foo = 'bla bla bla';
   
preg_match('/(?!\w)(0x[\p{N}]+[lL]?|[\p{Nd}]+(e[\p{Nd}]*)?[lLdDfF]?)(?!\w)/',
$foo);
?


Fatal error: Maximum execution time of 10 seconds exceeded in
/home/pberndt/- on line 4






-- 
Edit this bug report at http://bugs.php.net/?id=38600edit=1


#38600 [Opn]: libpcre needs update to 6.7: Infinite loop using preg_match

2006-08-26 Thread phillip dot berndt at googlemail dot com
 ID:   38600
 User updated by:  phillip dot berndt at googlemail dot com
-Summary:  Infinite loop in preg_match
 Reported By:  phillip dot berndt at googlemail dot com
 Status:   Open
 Bug Type: PCRE related
 Operating System: Linux
 PHP Version:  5.1.5
 New Comment:

Changed title to fit better. Sorry for posting another comment, I can't
submit the update without posting something :)

I just tested updating the php source to use the newest libpcre -
everything is working perfectly.


Previous Comments:


[2006-08-26 14:55:06] phillip dot berndt at googlemail dot com

This should be the problem:

ChangeLog for PCRE
--
Version 6.7 04-Jul-06
[...]
 4. When UTF-8 mode was not set, PCRE looped when compiling certain
patterns
containing an extended class (one that cannot be represented by a
bitmap
because it contains high-valued characters or Unicode property
items, e.g.
[\pZ]). Almost always one would set UTF-8 mode when processing such
a
pattern, but PCRE should not loop if you do not (it no longer
does).
[Detail: two cases were found: (a) a repeated subpattern containing
an
extended class; (b) a recursive reference to a subpattern that
followed a
previous extended class. It wasn't skipping over the extended
class
correctly when UTF-8 mode was not set.]
[...]



[2006-08-26 13:40:16] phillip dot berndt at googlemail dot com

Same result for a fresh php5.2-200608261230 build.

I don't know, whether this helps, but in this build I interrupted the
process after about 10 seconds; here's the bt:

#0  adjust_recurse (group=0x84706db R, adjust=1, utf8=0,
cd=0xbfd088e0) at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:1117
#1  0x08080269 in compile_regex (options=0, oldims=0,
brackets=0xbfd084a4, codeptr=0xbfd08344, ptrptr=0xbfd0837c,
errorcodeptr=0xbfd084dc, lookbehind=0,
skipbytes=0, firstbyteptr=0x0, reqbyteptr=0x0, bcptr=0x3d,
cd=0xbfd088e0) at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:2681
#2  0x0807e71a in compile_regex (options=0, oldims=0,
brackets=0xbfd084a4, codeptr=0xbfd084a8, ptrptr=0xbfd084d8,
errorcodeptr=0xbfd084dc, lookbehind=0,
skipbytes=0, firstbyteptr=0x0, reqbyteptr=0x0, bcptr=0x3d,
cd=0xbfd088e0) at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:3177
#3  0x08081339 in php_pcre_compile2 (pattern=0xb7bdf6d8
(?!\\w)(0x[\\p{N}]+[lL]?|[\\p{Nd}]+(e[\\p{Nd}]*)?[lLdDfF]?)(?!\\w),
options=0, errorcodeptr=0x0,
errorptr=0xbfd089a4, erroroffset=0xbfd089a8, tables=0x8470220 )
at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:4983
#4  0x080829a3 in php_pcre_compile (pattern=0x0, options=0,
errorptr=0x0, erroroffset=0x0, tables=0x0)
at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/pcrelib/pcre_compile.c:3905
#5  0x0808bfad in pcre_get_compiled_regex_cache (regex=0xb7be4bd4
/(?!\\w)(0x[\\p{N}]+[lL]?|[\\p{Nd}]+(e[\\p{Nd}]*)?[lLdDfF]?)(?!\\w)/,
regex_len=64)
at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/php_pcre.c:324
#6  0x0808d225 in php_do_pcre_match (ht=2, return_value=0xb7be4c20,
return_value_ptr=0x0, this_ptr=0x0, return_value_used=0, global=0)
at
/home/pberndt/php_snap/php5.2-200608261230/ext/pcre/php_pcre.c:457
#7  0x082292d7 in zend_do_fcall_common_helper_SPEC
(execute_data=0xbfd08b60) at zend_vm_execute.h:200
#8  0x08228bdc in execute (op_array=0xb7be47d8) at
zend_vm_execute.h:92
#9  0x0820dabe in zend_execute_scripts (type=8, retval=0x0,
file_count=3) at
/home/pberndt/php_snap/php5.2-200608261230/Zend/zend.c:1095
#10 0x081cfb86 in php_execute_script (primary_file=0xbfd0b060) at
/home/pberndt/php_snap/php5.2-200608261230/main/main.c:1759
#11 0x082963b0 in main (argc=1, argv=0xbfd0b144) at
/home/pberndt/php_snap/php5.2-200608261230/sapi/cli/php_cli.c:1102



[2006-08-25 21:39:04] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip





[2006-08-25 21:14:47] phillip dot berndt at googlemail dot com

Description:

When executing the code below, the function won't return but loop
forever (or do something else, I don't know).

Reproduce code:
---
?php
$foo = 'bla bla bla';
   
preg_match('/(?!\w)(0x[\p{N}]+[lL]?|[\p{Nd}]+(e[\p{Nd}]*)?[lLdDfF]?)(?!\w)/',
$foo);
?

Expected result:

Something like that:

[EMAIL PROTECTED] ~ $ time perl -e '$_=bla bla bla;
/(?!\w)(0x[\p{N}]+[lL]?|[\p{Nd}]+(e[\p{Nd}]*)?[lLdDfF]?)(?!\w)/;'

real0m0.017s
user0m0.016s
sys 0m0.000s


Actual result:
--
[EMAIL

#38600 [NEW]: Infinite loop in preg_match

2006-08-25 Thread phillip dot berndt at googlemail dot com
From: phillip dot berndt at googlemail dot com
Operating system: Linux
PHP version:  5.1.5
PHP Bug Type: PCRE related
Bug description:  Infinite loop in preg_match

Description:

When executing the code below, the function won't return but loop forever
(or do something else, I don't know).

Reproduce code:
---
?php
$foo = 'bla bla bla';
   
preg_match('/(?!\w)(0x[\p{N}]+[lL]?|[\p{Nd}]+(e[\p{Nd}]*)?[lLdDfF]?)(?!\w)/',
$foo);
?

Expected result:

Something like that:

[EMAIL PROTECTED] ~ $ time perl -e '$_=bla bla bla;
/(?!\w)(0x[\p{N}]+[lL]?|[\p{Nd}]+(e[\p{Nd}]*)?[lLdDfF]?)(?!\w)/;'

real0m0.017s
user0m0.016s
sys 0m0.000s


Actual result:
--
[EMAIL PROTECTED] ~ $ php
?php
set_time_limit(10);
$foo = 'bla bla bla';
   
preg_match('/(?!\w)(0x[\p{N}]+[lL]?|[\p{Nd}]+(e[\p{Nd}]*)?[lLdDfF]?)(?!\w)/',
$foo);
?


Fatal error: Maximum execution time of 10 seconds exceeded in
/home/pberndt/- on line 4


-- 
Edit bug report at http://bugs.php.net/?id=38600edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=38600r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=38600r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=38600r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38600r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=38600r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=38600r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=38600r=needscript
Try newer version:http://bugs.php.net/fix.php?id=38600r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=38600r=support
Expected behavior:http://bugs.php.net/fix.php?id=38600r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=38600r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=38600r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38600r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=38600r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38600r=dst
IIS Stability:http://bugs.php.net/fix.php?id=38600r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=38600r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=38600r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=38600r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=38600r=mysqlcfg