From:             
Operating system: Linux
PHP version:      5.3.2
Package:          Directory function related
Bug Type:         Bug
Bug description:readdir(false) behavior change

Description:
------------
Documentation at http://php.net/readdir explains that



> This function may return Boolean FALSE, but may also return a non-Boolean
value which evaluates to FALSE, such as 0 or "". Please read the section on
Booleans for more information. Use the === operator for testing the return
value of this function.



That was true for PHP 5.2.x and not so for 5.3.x:



# php -r 'var_dump(phpversion(), @readdir(false),
@readdir(false)===false);'

string(8) "5.2.11-2"

bool(false)

bool(true)



# php -r 'var_dump(phpversion(), @readdir(false),
@readdir(false)===false);'

string(7) "5.3.2-1"

NULL

bool(false)



This can make loop while (false !== ($file = readdir($handle))) {...}
infinite if $handle was not checked beforehand.



Please consider to be more backward-compatible if this not cost much.



Thanks!



Test script:
---------------
php -r 'var_dump(@readdir(false), @readdir(false)===false);'             



Expected result:
----------------
bool(false)

bool(true)



Actual result:
--------------
NULL

bool(false)



-- 
Edit bug report at http://bugs.php.net/bug.php?id=52383&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52383&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52383&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52383&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52383&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52383&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52383&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52383&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52383&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52383&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52383&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52383&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52383&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52383&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52383&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52383&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52383&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52383&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52383&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52383&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52383&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52383&r=mysqlcfg

Reply via email to